0

I have to download an excel file from a website through code. But the downloading requires logging into a website. So I am confused that what data should I post to login from code.

Here's the request from 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
4

2 回答 2

0

我进行了更多探索,发现我没有通过 SSL 进行身份验证,我收到了这个异常:无法为 SSL/TLS 安全通道建立信任关系

所以我从中得到了一段代码

System.Net.ServicePointManager.ServerCertificateValidationCallback = (senderX, 证书, 链, sslPolicyErrors) => { return true; };

它解决了我的问题

于 2013-08-21T15:38:50.803 回答
0

如果您搜索简单的解决方案,请尝试使用该WebBrowser控件。您可以遍历页面的所有项目并设置用户名和密码,然后单击登录按钮。

于 2013-08-21T13:10:35.780 回答