110,546
社区成员
发帖
与我相关
我的任务
分享
private void button_start_Click(object sender, EventArgs e)
{
if (textBox_url.Text.Replace("http://", "") != "")
{
domain = textBox_url.Text.Replace("http://", "").Replace("www.", "");
String htmlcode =dopost("论文" + " site:" + domain);
MessageBox.Show(htmlcode);
}
else
{
MessageBox.Show("The Target is Null,Fuck you!");
}
}
public String dopost(String keyword)
{
Encoding myEncoding = Encoding.GetEncoding("gb2312");
string param = HttpUtility.UrlEncode("hl", myEncoding) + "=" + HttpUtility.UrlEncode("zh-CN", myEncoding) + "&"
+ HttpUtility.UrlEncode("num", myEncoding) + "=" + HttpUtility.UrlEncode("100", myEncoding) + "&"
+ HttpUtility.UrlEncode("q", myEncoding) + "=" + HttpUtility.UrlEncode(keyword, myEncoding);
byte[] postBytes = Encoding.ASCII.GetBytes(param);
HttpWebRequest req = (HttpWebRequest)HttpWebRequest.Create("http://www.google.com.hk/search?"+param);
req.Method = "GET";
req.ContentType = "application/x-www-form-urlencoded;charset=gb2312";
req.ContentLength = postBytes.Length;
WebResponse wr = null;
try
{
wr = req.GetResponse();
}
catch
{
label_status.Text = "网络连接错误,没插网线吧!";
}
using (wr)
{
StreamReader sr = new StreamReader(wr.GetResponseStream());
return sr.ReadToEnd();
}
}
public String dopost(String keyword)
{
Encoding myEncoding = Encoding.GetEncoding("gb2312");
string param = HttpUtility.UrlEncode("hl", myEncoding) + "=" + HttpUtility.UrlEncode("zh-CN", myEncoding) + "&"
+ HttpUtility.UrlEncode("num", myEncoding) + "=" + HttpUtility.UrlEncode("100", myEncoding) + "&"
+ HttpUtility.UrlEncode("q", myEncoding) + "=" + HttpUtility.UrlEncode(keyword, myEncoding);
byte[] postBytes = Encoding.ASCII.GetBytes(param);
HttpWebRequest req = (HttpWebRequest)HttpWebRequest.Create("http://www.google.com.hk/search?"+param);
req.Method = "GET";
req.ContentType = "application/x-www-form-urlencoded;charset=gb2312";
req.ContentLength = postBytes.Length;
WebResponse wr = null;
try
{
wr = req.GetResponse();
}
catch
{
label_status.Text = "网络连接错误,没插网线吧!";
}
using (wr)
{
StreamReader sr = new StreamReader(wr.GetResponseStream(),Encoding.GetEncoding("gb2312"));
String str=sr.ReadToEnd();
req.Abort();
wr.Close();
return str;
}
}