通过代码登录网站
本文关键字:网站 登录 代码 | 更新日期: 2023-09-27 18:28:39
我必须通过代码从网站下载excel文件。但下载需要登录网站。所以我很困惑,我应该发布什么数据从代码登录。
以下是chrome的请求:
Request URL:https://206.82.192.135:4100/wgcgi.cgi?action=fw_logon&style=fw_logon.xsl&fw_logon_type=status
Request Method:POST
Status Code:200 OK
Request Headersview source
Accept:text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Encoding:gzip,deflate,sdch
Accept-Language:en-US,en;q=0.8
Cache-Control:max-age=0
Connection:keep-alive
Content-Length:884
Content-Type:multipart/form-data; boundary=----WebKitFormBoundaryPAzPZF4h5AQHA6Ic
Cookie:domain=null; username=CandA
Host:206.82.192.135:4100
Origin:https://206.82.192.135:4100
Referer:https://206.82.192.135:4100/wgcgi.cgi?action=fw_logon&style=fw_logon.xsl&fw_logon_type=status
User-Agent:Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/28.0.1500.95 Safari/537.36
Query String Parametersview sourceview URL encoded
action:fw_logon
style:fw_logon.xsl
fw_logon_type:status
Request Payload
------WebKitFormBoundaryPAzPZF4h5AQHA6Ic
Content-Disposition: form-data; name="fw_username"
[username appears here]
------WebKitFormBoundaryPAzPZF4h5AQHA6Ic
Content-Disposition: form-data; name="fw_password"
[password appears here]
------WebKitFormBoundaryPAzPZF4h5AQHA6Ic
Content-Disposition: form-data; name="fw_domain"
Firebox-DB
------WebKitFormBoundaryPAzPZF4h5AQHA6Ic
Content-Disposition: form-data; name="fw_domain"
Firebox-DB
------WebKitFormBoundaryPAzPZF4h5AQHA6Ic
Content-Disposition: form-data; name="submit"
Login
------WebKitFormBoundaryPAzPZF4h5AQHA6Ic
Content-Disposition: form-data; name="action"
fw_logon
------WebKitFormBoundaryPAzPZF4h5AQHA6Ic
Content-Disposition: form-data; name="style"
fw_logon_progress.xsl
------WebKitFormBoundaryPAzPZF4h5AQHA6Ic
Content-Disposition: form-data; name="fw_logon_type"
logon
------WebKitFormBoundaryPAzPZF4h5AQHA6Ic--
Response Headersview source
Connection:close
Content-Length:289
Content-Type:text/xml
Date:Wed, 21 Aug 2013 13:00:10 GMT
Server:None
如果您搜索一个简单的解决方案,请尝试使用WebBrowser
控件。您可以遍历页面的所有项目,设置用户名和密码,然后单击登录按钮。
我进行了更多的探索,发现我没有通过SSL的身份验证,我得到了这个异常:无法为SSL/TLS安全通道建立信任关系
所以我从这个
System.Net.ServicePointManager.ServerCertificateValidationCallback=(senderX,certificate,chain,sslPolicyErrors)=>{return true;};
它解决了我的问题