|
发表于 2015-6-1 20:41:44
|
显示全部楼层
- string url = "http://data.zz.baidu.com/urls?site=www.xxx.com&token=YourToken";( _0 u( s! A3 S% B, Z6 E1 v- @
- string postString = "http://www.xxx.com/abc.aspx";2 D( {3 W' z' T0 d8 R
- byte[] postData = Encoding.UTF8.GetBytes(postString);3 o f& z( P+ C# C( W3 C0 T
- WebClient myWebClient = new WebClient();
7 y% S5 [3 r: B% l! o) y - myWebClient.Headers.Add("UserAgent", "curl/7.12.1");0 Q7 s) D/ y; U/ @. Q/ ]' c7 M8 }
- myWebClient.Headers.Add("Content-Type", "text/plain");) i# ]/ ]4 N7 z8 e; M& f( A, {. g
- myWebClient.Credentials = CredentialCache.DefaultCredentials;
* T- H' E- @2 ^' H7 {( @ - byte[] myDataBuffer = myWebClient.UploadData(url, "post", postData);
+ c9 g$ l+ a5 ]4 X v2 d; X) J - string strWebData = Encoding.Default.GetString(myDataBuffer);! X+ W# L6 ]4 P2 @, x
- Response.Write(strWebData);
复制代码
' Q1 I1 C8 ~. [6 d( x) L. j拿去用,改成自己的URL和token |
评分
-
查看全部评分
|