首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >在powershell中运行Invoke-WebRequest生成403错误

在powershell中运行Invoke-WebRequest生成403错误
EN

Stack Overflow用户
提问于 2022-09-01 15:35:28
回答 1查看 26关注 0票数 -1

我想使用powershell登录网站:https://uk.blsspainvisa.com/visa4spain/login,我使用我的Chrome可以打开网站,而当我使用Invoke-WebRequest登录时,我得到了403错误。有人能帮我吗?谢谢。

在这里输入图像描述

EN

回答 1

Stack Overflow用户

发布于 2022-09-02 07:04:00

把它放在这里,因为它太长了,一个正常的评论。

一些网站积极阻止一些,如果不是全部自动化的努力。

所以,如果这个网站是其中之一,那么这不是一个PowerShell问题。

您还必须对所有基于SSL的站点使用TLS。

代码语言:javascript
运行
复制
[Net.ServicePointManager]::SecurityProtocol = [Net.ServicePointManager]::SecurityProtocol -bor [Net.SecurityProtocolType]::Tls12

一些网站,强迫你浏览一个登陆页面,快速测试发布的URL证明了这一点,视情况而定。

粘贴您在MSEdge、FF、Chrome中显示的确切URL,所有这些都显示了拒绝访问的页面。为什么,因为它期待的东西,从上一页。使用基本URL,显示登陆页面,其中必须首先从下拉框中提供国家。

如果在基本站点上使用调用-WebRequest,您也会被拒绝,.

代码语言:javascript
运行
复制
[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是它下面的所有资源。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/73572041

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档