62,046
社区成员
发帖
与我相关
我的任务
分享
private string getUrlRespHtml(string url, Dictionary<string, string> postDict)
{
string respHtml = "";
//HttpWebResponse resp = getUrlResponse(url, headerDict, postDict, timeout);
HttpWebResponse resp = getUrlResponse(url, postDict, "");
//long realRespLen = resp.ContentLength;
StreamReader sr;
sr = new StreamReader(resp.GetResponseStream(), System.Text.Encoding.GetEncoding("GB2312"));
respHtml = sr.ReadToEnd();
return respHtml;
}
private string getUrlRespHtml(string url, Dictionary<string, string> postDict)
{
string respHtml = "";
//HttpWebResponse resp = getUrlResponse(url, headerDict, postDict, timeout);
HttpWebResponse resp = getUrlResponse(url, postDict, "");
//long realRespLen = resp.ContentLength;
StreamReader sr;
sr = new StreamReader(resp.GetResponseStream(), System.Text.Encoding.GetEncoding("GB2312"));
respHtml = sr.ReadToEnd();
return respHtml;
}
string loginRespHtml = null;
Dictionary<string, string> postDict = new Dictionary<string, string>();
postDict.Add("__VIEWSTATE", "dDwtMTUxNzM0MjM0Mjs7Pot0nxzpyf7s6ZEFm%2F41QONw9iU9");
//postDict.Add("codestring", "");
postDict.Add("TextBox1",textBox1.Text);
postDict.Add("TextBox2", textBox2.Text);
postDict.Add("RadioButtonList1", "%D1%A7%C9%FA");
postDict.Add("Button1", "");
postDict.Add("lbLanguage", "");
string baiduMainUrl = "http://61.139.105.138/xs_main.aspx";
loginRespHtml = getUrlRespHtml(baiduMainUrl, postDict);
MessageBox.Show(loginRespHtml);
webBrowser1.Navigate("about:blank");
while (webBrowser1.ReadyState != WebBrowserReadyState.Complete)
{
Application.DoEvents();
}
webBrowser1.Document.Write(ConvertExtendedASCII(loginRespHtml));
这是按按钮登录的代码。