我想在服务器上运行Web抓取脚本。Power Shell Web Scraping SSL/TSL问题
当前脚本收集指定页面上的html。
$url = "http://websms"
[net.httpWebRequest] $request = [net.webRequest]::create($url)
[net.httpWebResponse] $response = $request.getResponse()
$responseStream = $response.getResponseStream()
$sr = new-object IO.StreamReader($responseStream)
$result = $sr.ReadToEnd()
$result
这在一个典型的网页上正常工作。不过,我想在服务器管理页面上运行它,当然这需要登录。
我想在我尝试登录之前,我会尝试和刮去服务器的登录页面。运行上面的脚本,我得到以下结果。
Exception calling "GetResponse" with "0" argument(s): "The underlying connection was closed: Could not establish trust relationship for the SSL/TLS secure channel."
At C:\temp\web3.ps1:3 char:56
+ [net.httpWebResponse] $response = $request.getResponse <<<<()
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : DotNetMethodException
如何来解决这个问题,或者是如果你能指出我不同的方向,所以我可以刮去的服务器的管理员HTML页面元素的任何想法。
谢谢!
非常感谢! – 2012-03-29 01:54:39
并恢复,只需执行'[System.Net.ServicePointManager] :: ServerCertificateValidationCallback = $ null' – mousio 2012-12-20 14:17:43
非常感谢! – hupseb 2014-06-24 10:07:41