|
发表于 2015-6-1 20:41:44
|
显示全部楼层
- string url = "http://data.zz.baidu.com/urls?site=www.xxx.com&token=YourToken";+ m7 n. x9 D4 y# G0 P4 K
- string postString = "http://www.xxx.com/abc.aspx";
/ o4 m& ~/ k0 W7 b6 c# H, U - byte[] postData = Encoding.UTF8.GetBytes(postString);
2 N; q0 x% u7 d v - WebClient myWebClient = new WebClient();
. D- @3 P5 A9 F# L) M- {0 w - myWebClient.Headers.Add("UserAgent", "curl/7.12.1");; ~$ ^# G" t4 m; x# |4 d
- myWebClient.Headers.Add("Content-Type", "text/plain");
* O. p, z& D) x - myWebClient.Credentials = CredentialCache.DefaultCredentials;
# X8 w3 C: l2 c7 R \# s) u - byte[] myDataBuffer = myWebClient.UploadData(url, "post", postData);( w- z$ B/ t4 O3 d$ `: s
- string strWebData = Encoding.Default.GetString(myDataBuffer);
. {) J4 N- ~9 r - Response.Write(strWebData);
复制代码 , w( W+ J e- e: w/ ?8 O# B0 P. c
拿去用,改成自己的URL和token |
评分
-
查看全部评分
|