如何使用winInet.dll下载WebPage内容
代码(来自评论):
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();
答案 0 :(得分:1)
尝试以下代码。如果它不起作用..这肯定是服务器方面的问题:
string s;
using (WebClient wc = new WebClient()) {
s = wc.DownloadString("http://www.blahblah.com"); // put your url here.
}