|
发表于 2015-6-1 20:41:44
|
显示全部楼层
- string url = "http://data.zz.baidu.com/urls?site=www.xxx.com&token=YourToken";2 O* O8 C/ K, |8 s
- string postString = "http://www.xxx.com/abc.aspx";
. ~& v9 H& m! x; h q* E7 T( |) z/ E - byte[] postData = Encoding.UTF8.GetBytes(postString);4 J9 c( j. O! M' E/ e+ y
- WebClient myWebClient = new WebClient();
6 ^; I* \' C4 V* ]0 k - myWebClient.Headers.Add("UserAgent", "curl/7.12.1");( G* K8 O4 ?. ?! i
- myWebClient.Headers.Add("Content-Type", "text/plain");4 l3 d4 |- q8 P1 l. e1 y
- myWebClient.Credentials = CredentialCache.DefaultCredentials;$ j( I+ `. \) [* _- c9 \
- byte[] myDataBuffer = myWebClient.UploadData(url, "post", postData);
' B; X" r, S- f y- A - string strWebData = Encoding.Default.GetString(myDataBuffer);
4 [' @6 {) C3 c) W: F - Response.Write(strWebData);
复制代码
. X. q' Z' w6 t% l拿去用,改成自己的URL和token |
评分
-
查看全部评分
|