我不知道如何以编程方式登录到此site 我已通过stackoverflow搜索并找到this,但我仍然不知道要将什么放入URL或URI。如何以编程方式登录到网站
回答
当我只需输入用户名“ABC”和密码“高清”和按下按钮,我得到了下面的帖子数据:
下一个=应用程式%2Flinks%2F &为什么= PW &电子邮件= ABC &密码=高清& fw_human =
所以这使我beleive如果你只是使用POST数据和相应的信息替换它,你可以模拟手动登录。
所以从你链接的堆栈溢出,这将采取以下形式:
string formUrl = "http://ratings-plus.webs.com/apps/auth/doLogin"; // NOTE: This is the URL the form POSTs to, not the URL of the form (you can find this in the "action" attribute of the HTML's form tag
string formParams = string.Format("next=apps%2Flinks%2F&why=pw&email={0}&password={1}&fw_human=", "your email", "your password");
string cookieHeader;
WebRequest req = WebRequest.Create(formUrl);
req.ContentType = "application/x-www-form-urlencoded";
req.Method = "POST";
byte[] bytes = Encoding.ASCII.GetBytes(formParams);
req.ContentLength = bytes.Length;
using (Stream os = req.GetRequestStream())
{
os.Write(bytes, 0, bytes.Length);
}
WebResponse resp = req.GetResponse();
cookieHeader = resp.Headers["Set-cookie"];
注意,在将来的请求,你需要再使用任何返回给维护您的认证状态cookie的值。
我试过了,但没有帮助。我仍然无法输入:http://ratings-plus.webs.com/apps/links/使用我的登录cookie :( – Qbunia
我真的无法帮助了,因为我看不到头或任何成功的登录,要重用的cookie头可能包含在多个set-cookie头中,很难说没有看到响应数据。您是否使用过像Fiddler或Firebug这样的工具或Chome开发工具来观察网络流量?这样您就可以查看手动登录的请求和响应标题和数据,并将其与您的程序化登录进行比较以查看缺失的部分。 –
- 1. 以编程方式登录到网站
- 2. 如何以编程方式登录/登录网站?
- 3. 以编程方式登录网站
- 4. 以编程方式登录网站
- 5. 以编程方式登录网站
- 6. 编程方式登录到网站
- 7. 如何以编程方式登录到雅虎网站
- 8. 如何以编程方式登录到网站?
- 9. 如何以编程方式登录到mediawiki网站
- 10. 如何使用asp.net以编程方式登录到网站
- 11. 如何以编程方式从服务器登录网站
- 12. 使用c#/ ASP.NET以编程方式伪造登录到网站
- 13. 以编程方式使用OAuth登录到其他网站
- 14. 以编程方式登录到asp.net中的网站
- 15. 不能以编程方式执行登录到网站
- 16. Android:如何以编程方式登录到网页,使用HttpsURLConnection
- 17. 如何以编程方式登录wordpress?
- 18. 使用C#以编程方式登录网站
- 19. 以编程方式在网站上登录
- 20. 使用C#以编程方式登录网站#
- 21. 以编程方式登录到SSRS
- 22. 以编程方式登录到Zimbra
- 23. 以编程方式登录到MySQL
- 24. 以编程方式登录到OKC
- 25. 以编程方式登录到Windows XP
- 26. 以编程方式登录到PureVolume.com!
- 27. 以编程方式登录到msn messenger
- 28. Android/Java:以编程方式登录到Android应用程序的网站
- 29. Android:如何以编程方式登录网站并从中检索数据?
- 30. Scala-Dispatch |登录到网站可编程
使用[本答案](http://stackoverflow.com/questions/930807/c-sharp-login-to-website-via-program/931030#931030)中的代码并更改URL和表单参数。 –