Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/75.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/vb.net/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
VB.NET使用Internet Explorer自动将网站保存为HTML_Html_Vb.net_Internet Explorer_Automation - Fatal编程技术网

VB.NET使用Internet Explorer自动将网站保存为HTML

VB.NET使用Internet Explorer自动将网站保存为HTML,html,vb.net,internet-explorer,automation,Html,Vb.net,Internet Explorer,Automation,我试图在VB.NET中开发一个简单的工具,在一个循环中导航到一个网站,并将页面保存为HTML文档 我可以很容易地设置循环,因为页面是按顺序编号的 www.example.com/pages/1.html www.example.com/pages/2.html www.example.com/pages/3.html www.example.com/pages/4.html 我遇到的问题是如何找到保存实际页面的方法。我打算使用一系列sendKey来Alt、File、saveas、Enter等。

我试图在VB.NET中开发一个简单的工具,在一个循环中导航到一个网站,并将页面保存为HTML文档

我可以很容易地设置循环,因为页面是按顺序编号的

www.example.com/pages/1.html
www.example.com/pages/2.html
www.example.com/pages/3.html
www.example.com/pages/4.html
我遇到的问题是如何找到保存实际页面的方法。我打算使用一系列sendKey来Alt、File、saveas、Enter等。。但我认为必须有某种对象/方法可以用来更直接地实现这一点

我已启用COM Internet控件引用和声明以及新的SHDoc.Vw.InternetExplorer,并且能够通过编程在新窗口中打开浏览器并导航到所需页面。我已在线搜索保存问题的解决方案,但未成功。有人有什么想法吗

Dim baseUrl As String = "http://www.example.com/pages/{0}.html"
Dim basePath As String = "C:\some\path{0}.html"
Using ws As New System.Net.WebClient()
    ForEach i As Integer In Enumerable.Range(1,4)
        wc.DownloadFile(String.Format(baseUrl, i), string.Format(basePath, i))           
    Next i
End Using
如果你有很多这样的想法,你甚至可以使用这个方法一次将其中的几个排好队