参考这个试试 我之前写的抓取的
[C#] 纯文本查看 复制代码 /// <summary>
/// 抓取网站内容(项目需求进行更改,抓folktel字段)
/// </summary>
/// <param name="webUrl">网站地址</param>
/// <param name="cookie">cookie</param>
/// <returns></returns>
public static string GetWebSourceFile(string webUrl,string cookie)
{
WebClient webClient = new WebClient();
webClient.Headers.Add("Cookie", cookie);
webClient.Credentials = CredentialCache.DefaultCredentials;
Stream stream = webClient.OpenRead(webUrl);
StreamReader reader = new StreamReader(stream);
string content = reader.ReadToEnd();
reader.Close();
stream.Close();
return content;
}
|