我尝试了一些方法来获取以下网站的页面源代码http://www.poppe-bedrijfswagens.nl
。我认为这个网站有一个自动重定向设置。
我尝试了以下方法:
WebClient client = new WebClient();
string sourceCode = "";
sourceCode = client.DownloadString(address);
和
HttpWebRequest myWebRequest = (HttpWebRequest)HttpWebRequest.Create(address);
myWebRequest.AllowAutoRedirect = true;
myWebRequest.Method = "GET";
// make request for web page
HttpWebResponse myWebResponse = (HttpWebResponse)myWebRequest.GetResponse();
StreamReader myWebSource = new StreamReader(myWebResponse.GetResponseStream());
string myPageSource = myWebSource.ReadToEnd();
myWebResponse.Close();
我总是获得第一页的源代码,但我需要获得网站重定向到的页面的源代码。
重定向为http://www.poppe-bedrijfswagens.nl
:
Type of redirect: “meta refresh” redirect after 0 second
Redirected to: http://www.poppe-bedrijfswagens.nl/daf-html/dealer_homepage.html
提前致谢