Powershell 2中的DownloadString 503错误

时间:2018-10-09 01:49:49

标签: powershell-v2.0 windows-7-x64

我正在研究一个脚本来刮取Google,以查看.csv文件中的某些网站是否包含某些短语。但是,一段时间后,我仍然遇到Powershell 503错误,这是因为Google拒绝了该连接。

代码如下:

$doc=import-csv logsoft.csv
$seek="Inventory management","Billing", "ERP", "SCM", "Dispatch", "Appointment scheduling", "Warehouse Management", "Supplier collaboration", "End-to-end supply";
for($i=0;$i -lt $doc.count;$i++){
    write-host 'Now scanning '  $doc[$i].Name  '...'
    $site='site:'+$doc[$i].URL
    for($j=0;$j -lt $seek.count;$j++){

    #$URI='www.google.com/search?q="' + $seek[$j] + '" ' + $site;
        #$HTML = invoke-webrequest -uri $URI
        write-host "I'm not broken, I'm thinking..."
        Try{$HTML=(New-Object System.Net.WebClient).DownloadString('https://www.google.com/search?q="' + $seek[$j] + '" ' + $site)}
        Catch{
        write-host 'Waiting 10 minutes. I broke down at' +  $doc[$i].name .
        start-sleep 600
        }
        if ($HTML -notmatch "No results found for" -or $HTML -notmatch "did not match any documents"){
            $index=$seek[$j]
            $doc[$i].$index='x'
        }

        start-sleep -s 10
        }

    }

$doc | export-csv 'logsoft_final.csv'

错误:

Exception calling "DownloadString" with "1" argument(s): "The remote server returned an error: (503) Server Unavailable.

关于如何解决此问题的任何想法?我尝试通过不同的IP进行VPN连接,但这似乎不起作用。

0 个答案:

没有答案
相关问题