我想使用powershell登录网站:https://uk.blsspainvisa.com/visa4spain/login,我使用我的Chrome可以打开网站,而当我使用Invoke-WebRequest登录时,我得到了403错误。有人能帮我吗?谢谢。
发布于 2022-09-02 07:04:00
把它放在这里,因为它太长了,一个正常的评论。
一些网站积极阻止一些,如果不是全部自动化的努力。
所以,如果这个网站是其中之一,那么这不是一个PowerShell问题。
您还必须对所有基于SSL的站点使用TLS。
[Net.ServicePointManager]::SecurityProtocol = [Net.ServicePointManager]::SecurityProtocol -bor [Net.SecurityProtocolType]::Tls12
一些网站,强迫你浏览一个登陆页面,快速测试发布的URL证明了这一点,视情况而定。
粘贴您在MSEdge、FF、Chrome中显示的确切URL,所有这些都显示了拒绝访问的页面。为什么,因为它期待的东西,从上一页。使用基本URL,显示登陆页面,其中必须首先从下拉框中提供国家。
如果在基本站点上使用调用-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
因此,...and是它下面的所有资源。
https://stackoverflow.com/questions/73572041
复制相似问题