|
|
发表于 2015-6-1 20:41:44
|
显示全部楼层
- string url = "http://data.zz.baidu.com/urls?site=www.xxx.com&token=YourToken";
7 O% H6 y6 ? c2 z: m - string postString = "http://www.xxx.com/abc.aspx";/ L/ C$ x! k- g) ^; |$ J% G
- byte[] postData = Encoding.UTF8.GetBytes(postString);
' I$ g/ Z, a' w0 r- y - WebClient myWebClient = new WebClient();$ ?2 g- F# Y! S) r& x6 p
- myWebClient.Headers.Add("UserAgent", "curl/7.12.1");
% I! V, O7 n& L; `) w - myWebClient.Headers.Add("Content-Type", "text/plain");
8 ^; ~; y' _$ H# s& T - myWebClient.Credentials = CredentialCache.DefaultCredentials;
$ e# S. Q3 Y; |' M/ Q$ s - byte[] myDataBuffer = myWebClient.UploadData(url, "post", postData);
# @- M/ j7 g3 b" W/ R - string strWebData = Encoding.Default.GetString(myDataBuffer);: i+ ]% v' w4 k2 N1 D
- Response.Write(strWebData);
复制代码
$ @4 q# j0 } n4 h5 i" ]拿去用,改成自己的URL和token |
评分
-
查看全部评分
|