|
|
发表于 2015-6-1 20:41:44
|
显示全部楼层
- string url = "http://data.zz.baidu.com/urls?site=www.xxx.com&token=YourToken";* ^; o" C# A4 w- i
- string postString = "http://www.xxx.com/abc.aspx";
) H* G6 B6 ?. s. \4 e( q$ J - byte[] postData = Encoding.UTF8.GetBytes(postString);3 |' g8 E/ e5 y0 E/ t, D& j2 V4 z
- WebClient myWebClient = new WebClient();
( y. ?; b8 H# M1 i8 { - myWebClient.Headers.Add("UserAgent", "curl/7.12.1");, `: t% f. I) h, w
- myWebClient.Headers.Add("Content-Type", "text/plain");
1 }0 x2 f& _( c. _, z# t7 P - myWebClient.Credentials = CredentialCache.DefaultCredentials;
# [; ?/ b$ T: B9 O* Q+ J' {! j - byte[] myDataBuffer = myWebClient.UploadData(url, "post", postData);8 W5 K8 g" n `5 S+ w- r' a& j
- string strWebData = Encoding.Default.GetString(myDataBuffer);2 {, S+ S! H% C% [
- Response.Write(strWebData);
复制代码 P% ?9 e Q5 U- f" J( b0 |4 N$ |1 W
拿去用,改成自己的URL和token |
评分
-
查看全部评分
|