[英]Powershell - Invoke-Webrequest (Error 503 when run via script)
[英]run Invoke-WebRequest in powershell generate 403 error
我想使用 powershell 登錄網站: https://uk.blsspainvisa.com/visa4spain/login ,我使用我的 Chrome 可以打開網站,而當我使用 Invoke-WebRequest 登錄時,我得到了 40 . 任何人都可以幫助我嗎? 謝謝。
把它放在這里,因為它對於正常的評論來說太長了。
一些網站主動阻止了一些(如果不是全部)自動化工作。
因此,如果此站點是其中之一,那么這不是 PowerShell 問題。
您還必須對所有基於 SSL 的站點使用 TLS。
[Net.ServicePointManager]::SecurityProtocol = [Net.ServicePointManager]::SecurityProtocol -bor [Net.SecurityProtocolType]::Tls12
一些網站,通過登錄頁面強迫您訪問 go,並且對已發布的 URL 的快速測試證明了這一點。
粘貼您在 MSEdge、FF、Chrome 中顯示的確切 URL,都顯示“拒絕訪問”頁面。 為什么,因為它期待上一頁的內容。 使用基礎 URL 顯示登錄頁面,您必須首先從下拉框中提供國家/地區。
如果您在基礎站點上使用 Invoke-WebRequest,您也會被拒絕,...
[Net.ServicePointManager]::SecurityProtocol = [Net.ServicePointManager]::SecurityProtocol -bor [Net.SecurityProtocolType]::Tls12
Invoke-WebRequest -Uri 'https://uk.blsspainvisa.com' -UseBasicParsing
Invoke-WebRequest : The remote server returned an error: (403) Forbidden.
At line:2 char:1
+ Invoke-WebRequest -Uri 'https://uk.blsspainvisa.com' -UseBasicParsing
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-WebRequest], WebException
+ FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeWebRequestCommand
...以及它下面的所有資源。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.