-5

如何使用 winInet.dll 下载网页内容

代码(来自评论):

url="http://links.casemakerlegal.com/states/TX/books/Case_Law/results?search[Cite]=359%20S.W.3d.%20856" Uri urlCheck = new Uri(url); 
WebClient wc = new WebClient(); 
wc.Headers.Add("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; .NET CLR 1.0.3705;)"); 
Stream data = wc.OpenRead(urlCheck); 
StreamReader reader = new StreamReader(data);
string s = reader.ReadToEnd();
4

1 回答 1

1

试试下面的代码。如果它不起作用..这绝对是服务器端问题:

string s;
using (WebClient wc = new WebClient()) {
    s = wc.DownloadString("http://www.blahblah.com"); // put your url here.
}
于 2013-02-06T03:58:32.537 回答