研究相关页面的源代码,直到您了解单击按钮时发送的 http 请求是什么。 由于隐藏的 ViewState 字段,这对于 asp.net 站点来说尤其棘手。
使用 WireShark 之类的工具来嗅探发送的数据包并从中逆向工作。
Is this your web site? If so, you can probably just call the click event for the button directly (assuming it causes a postback).
Are you scraping someone else's site? In that case, use a System.Net.WebClient or System.Net.HttpWebRequest object to send a similar request to the server that the browser would send if you click the button. There are two ways to find out what the request will be:
Study the source of the page in question until you understand what http request is sent when you click the button. This can be especially tricky for asp.net sites because of the hidden ViewState field.
Use something like WireShark to sniff the packet sent and work backwards from that.
发布评论
评论(2)
在服务器代码中,您可以使用 ClientScriptManager.GetPostBackEventReference 来呈现回发事件引用
这是msdn上的链接 http://msdn .microsoft.com/en-us/library/system.web.ui.page.getpostbackeventreference.aspx
这里是一个示例
允许选择 gridview 行而不选择列。
From server code you could use ClientScriptManager.GetPostBackEventReference which renders out a postback event reference
heres a link on msdn http://msdn.microsoft.com/en-us/library/system.web.ui.page.getpostbackeventreference.aspx
heres a sample
Allows selecting gridview row without select column.
这是您的网站吗? 如果是这样,您可能可以直接调用按钮的单击事件(假设它导致回发)。
你在抓取别人的网站吗? 在这种情况下,请使用
System.Net.WebClient
或System.Net.HttpWebRequest
对象向服务器发送与单击按钮时浏览器将发送的类似请求。 有两种方法可以查明请求的内容:Is this your web site? If so, you can probably just call the click event for the button directly (assuming it causes a postback).
Are you scraping someone else's site? In that case, use a
System.Net.WebClient
orSystem.Net.HttpWebRequest
object to send a similar request to the server that the browser would send if you click the button. There are two ways to find out what the request will be: