2013-02-06 201 views
-5

如何下載網頁內容的wininet.dll使用如何使用InternetOpen,InternetOpenUrl中和的InternetReadFile

代碼(從評論):

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

使用'WebClient'或'HttpClient'。 – SLaks

+0

我已經使用了,但我發現了「內部服務器錯誤」這就是爲什麼我去的wininet.dll庫.... –

+0

..that是在網站上側的錯誤.. –

回答

1

嘗試下面的代碼。如果它不起作用..這絕對是一個服務器端問題:

string s; 
using (WebClient wc = new WebClient()) { 
    s = wc.DownloadString("http://www.blahblah.com"); // put your url here. 
} 
+0

感謝ü但其給「500 - 內部服務器錯誤」 ...... 有任何其他替代????? –

+0

不是。這不是代碼問題。這是網站的問題。不知道如何告訴你。 –

+0

OK感謝ü...但因爲什麼問題服務器沒有響應...... 沒有任何安全問題.. ??? –

相關問題