今天我写了个爬虫,给大家康康吧
public static string HttpPost(string url, string paraJsonStr)
{
WebClient webClient = new WebClient();
webClient.Headers.Add("Content-Type", "application/x-www-form-urlencoded");
byte[] postData = System.Text.Encoding.UTF8.GetBytes(paraJsonStr);
...
byte[] responseData = webClient.UploadData(url, "POST", postData);
string returnStr = System.Text.Encoding.UTF8.GetString(responseData);
return returnStr;
}
本文介绍了如何在C#中使用WebClient类实现一个简单的HTTPPost爬虫,涉及参数编码、上传数据和接收响应的过程。
606

被折叠的 条评论
为什么被折叠?



