我有这个代码工作,但现在突然它不会返回 "响应状态代码不表示成功:404()" .. 什么可能是它不重要的URL ..
下面是代码:
protected async void getstring(string url)
{
HttpClient client = new HttpClient();
client.DefaultRequestHeaders.TryAddWithoutValidation("User-Agent", "Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:25.0) Gecko/20100101 Firefox/25.0");
try
{
var html = await client.GetStringAsync(url);
extractData(html);
}
catch (HttpRequestException e)
{
MessageBox.Show(e.Message);
arrivalTime.Text = e.Message;
}
//time.Text = html;
}