好的,我已经阅读了很多页面来尝试找到我的问题的答案,但我没有任何运气。基本上我想在 C# 中使用 HTTPWebRequest 来访问网页。这是我到目前为止所拥有的,它似乎不起作用。Wireshark 也不显示任何返回的 cookie。假设我已经宣布了我需要取悦的一切:
private void cmdVisit_Click(object sender, EventArgs e)
{
url = textBox1.Text;
string front = "http://";
string prx = front + lstProxy.Items[x].ToString();
WebProxy myProxy = new WebProxy(prx);
CookieContainer cookieJar = new CookieContainer();
HttpWebRequest request = HttpWebRequest.Create(url) as HttpWebRequest;
request.Method = "GET";
request.Proxy = myProxy;
request.Referer = "http://anyrefererItypehere";
request.CookieContainer = cookieJar;
request.ContentType = "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8";
request.KeepAlive = true;
request.Headers.Add(HttpRequestHeader.AcceptEncoding, "gzip, deflate");
request.UserAgent = "Mozilla/5.0 (Windows NT 5.1; rv:10.0.2) Gecko/20100101 Firefox/10.0.2";
request.Headers.Add(HttpRequestHeader.AcceptLanguage, "Accept-Language: en-us,en;q=0.5");
request.Host = "anyblogItypehere.tumblr.com";
HttpWebResponse webResponse;
webResponse = (HttpWebResponse)request.GetResponse();
Stream stream = webResponse.GetResponseStream();
StreamReader reader = new StreamReader(stream, Encoding.UTF8);
String responseString = reader.ReadToEnd();
webResponse.Close();
rtbSource.Text = responseString;
}