使用httpwebrequest登录网站 [英] Logging into a website with httpwebrequest
问题描述
我想登录这个网站
http://www.conquercl...p?game = 13025037
并使用httpwebrequest返回所有html
代码: -
I'm wanting to login to this website
http://www.conquercl...p?game=13025037
and return all the html using httpwebrequest
Code:-
1 var request = WebRequest.Create("http://www.conquerclub.com/game.php?game=13025037");
2 HttpWebResponse response = (HttpWebResponse)request.GetResponse();
3 StreamReader reader = new StreamReader(response.GetResponseStream());
4 string result = reader.ReadToEnd();
< br $> b $ b
这将按预期重新定向到登录页面并返回。我正在寻找一种方法来发送用户名和密码以自动登录并转到右侧页面。我已经看过很多类似的问题,并尝试了一些不同的东西,但可以得到任何工作。它总是重新定向,只能返回登录页面。我是一个不错的c#程序员,但是不太了解Web登录的东西如何与PHP e.t.c一起使用。我已经花了几个小时试图解决这个问题,所以如果有人能为我提供一些代码,那将使我的工作非常受欢迎。
登录详情(这是我创建的真实账户)
用户名 - testuser1
密码 - 测试
This re-directs to the login page as expected and returns that. I'm looking for a way to send the username and password to automatically login and go to the right page. I've already had a look of lots of similar questions and tried a few different things but can;t get anything to work. It always re-directs and can only ever get the login page back. I'm a decent c# programmer but don't really understand how the web login stuff works with PHP e.t.c. I've already spent several hours trying to figure this out so if anyone can provide me with a bit of code that will make this work will be hugely appreciated.
login details (this is a real account I've created)
username - testuser1
password - testing
推荐答案
检查这些..
http://stackoverflow.com/questions/975426/how-to-programmatically-log-in-to-a-website-to-screenscape [ ^ ]
http://stackoverflow.com/questions/4699938/how-to-download-the-file-using-httpwebreq uest-and-httpwebresponse-classcookies / 4704065#4704065 [ ^ ]
http://stackoverflow.com/questions/1282602/how-to-login-to-wordpress-programmatically [ ^ ]
Check these..
http://stackoverflow.com/questions/975426/how-to-programmatically-log-in-to-a-website-to-screenscape[^]
http://stackoverflow.com/questions/4699938/how-to-download-the-file-using-httpwebrequest-and-httpwebresponse-classcookies/4704065#4704065[^]
http://stackoverflow.com/questions/1282602/how-to-login-to-wordpress-programmatically[^]
这篇关于使用httpwebrequest登录网站的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!