private void btnWininetGet_Click(object sender, EventArgs e) { Random r = new Random(); string str = wnet.GetData("http://www.baidu.com"); //正常请求. txtInfo.Text = str; wnet.WininetTimeOut = 5000; string str1 = wnet.GetData("http://www.google.com"); //测试超时,超时后返回长度为0的字符串 MessageBox.Show(str1); }
private void button7_Click(object sender, EventArgs e) { Wininet wi = new Wininet(); StringBuilder sb = new StringBuilder(); sb.Append("Accept:text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8\r\n"); sb.Append("Content-Type:application/x-www-form-urlencoded\r\n"); sb.Append("Accept-Language:zh-cn\r\n"); sb.Append("Referer:" + "http://mrtx.u193.com/");//增加referer头 string str = wi.PostData("http://www.u193.com/opt.php?do=login", "username=ceshiyixia1&password=111111", sb); str = wi.GetData("http://mrtx.u193.com/"); }
public static String getProxyIpAndPort() { Wininet wininet = new Wininet(); String result = wininet.GetData("http://api.ip.data5u.com/dynamic/get.html?order=61fbc26a3a7cd3f62bf8be2e7a60c83a&ttl=1&sep=3"); //返回的格式 222.185.146.193:39441,16361 if (result.Contains(",")) { return(result.Split(',')[0]); } else { return(result); } }