[英]How do I follow a Javascript Link without onClick
This is my first time posting. 这是我第一次发贴。 I've been working on a "web scraper" to navigate through a website and download an Excel File or .CSV file automatically.
我一直在研究“网页抓取工具”,以浏览网站并自动下载Excel文件或.CSV文件。
I'm running into a problem when I want to download the file. 我要下载文件时遇到问题。 Here is the HTML:
这是HTML:
<"a class="PSQRYRESULTSTITLE" href="javascript: bSubmitted=false;submitAction_win2(document.win2,'#ICQryDownloadRaw');">CSV Text File<"/a>
When clicked it opens a download prompt to save. 单击后,将打开一个下载提示以保存。
I'm coding this in Visual Studio C# 2008. I am using a WebBrowser Control to navigate through the website. 我在Visual Studio C#2008中对此进行编码。我正在使用WebBrowser控件浏览网站。
I've tried everything from webbrowser1.document.invokescript
to storing all the elements in an HtmlElementCollection traversing through them and doing invokemember("click")... 我尝试了所有内容,从
webbrowser1.document.invokescript
到将所有元素存储在遍历它们并执行invokemember(“ click”)的HtmlElementCollection中...
Nothing is working! 什么都没用! Please help!
请帮忙!
"javascript: bSubmitted=false;submitAction_win2(document.win2,'#ICQryDownloadRaw');"
"javascript: bSubmitted=false;submitAction_win2(document.win2,'#ICQryDownloadRaw');"
UrlDownloadToFile
to download it to your location, or make another web request to download the file if UrlDownloadToFile
fails. UrlDownloadToFile
将其下载到您的位置;如果UrlDownloadToFile
失败,则可以提出另一个Web请求以下载文件。 foreach (HtmlElement i in webBrowser1.Document.All)
{
if (i.OuterText == "CSV Text File" && i.GetAttribute("href") != "")
{
webBrowser1.Navigate(i.GetAttribute("href"));
}
}
although this doesn't answer my second question of how to automatically download the file or disable the prompt it got me moving forward finally. 虽然这不能回答我的第二个问题,即如何自动下载文件或禁用提示,但最终还是让我前进了。 But if anyone has an answer for that it would be much appreciated.
但是,如果有人对此有答案,将不胜感激。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.