我有一个简单的函数来爬取网页,但是针对某个特定页面,下面的代码突然出现了503错误:
try
{
WebClient client = new WebClient();
client.Proxy = null;
string webhtml = client.DownloadString(strURL);
client.Dispose();
return (webhtml);
}
当我在IE或FF中输入URL时,它可以正常工作,但是在运行此代码时返回错误。其他URL正常工作。我猜测从.net发出的http请求与任一浏览器不同。有没有更好的方法来模拟基于浏览器的http请求呢?
谢谢。