Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/.net/24.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
.net 启动ie并保存页面_.net_Internet Explorer_Powershell - Fatal编程技术网

.net 启动ie并保存页面

.net 启动ie并保存页面,.net,internet-explorer,powershell,.net,Internet Explorer,Powershell,我需要启动IE,浏览到许多不同的网站,并保存我浏览到的页面。net可以像这样与IE一起工作吗?或者脚本是更好的方法吗?如果您只想保存页面,请执行类似操作。这里是html,而不是页面的屏幕截图 string url = "http://google.com"; string strResult = ""; WebResponse objResponse; WebRequest objRequest = System.Net.HttpWebRequest.Create

我需要启动IE,浏览到许多不同的网站,并保存我浏览到的页面。net可以像这样与IE一起工作吗?或者脚本是更好的方法吗?

如果您只想保存页面,请执行类似操作。这里是html,而不是页面的屏幕截图

    string url = "http://google.com";
    string strResult = "";
    WebResponse objResponse;
    WebRequest objRequest = System.Net.HttpWebRequest.Create(url);
    objResponse = objRequest.GetResponse();
    using (StreamReader sr = new StreamReader(objResponse.GetResponseStream()))
    {
        strResult = sr.ReadToEnd();
        // Close and clean up the StreamReader
        sr.Close();
    }
    // Display results to a webpage
    //Response.Write(strResult);
    Console.WriteLine(strResult);
    Console.ReadKey();

如果您需要页面的图片,请使用autoit或watin之类的工具。

我建议为此使用类。您可以加载站点,然后使用其事件处理程序保存网页

公认的答案太复杂了。如果您确实只需要下载源html,请使用以下功能:

function Download-Page([string]$url) {
  $w = New-Object net.webclient
  $w.DownloadString($url)
}
然后可以按如下方式保存内容:

Download-Page http://www.google.com | Set-Content d:\google.html

(这也适用于本地主机URL)

保存页面是什么意思?