![](/img/trans.png)
[英]C# WCF “System.Net.WebException: The remote server returned an error: (400) Bad Request.”
[英]System.Net.WebException: 'The remote server returned an error: (400) Bad Request.' when trying to download data from google server
我正在使用WebClient从cbk0.google.com下载图像,但开始出现错误System.Net.WebException: 'The remote server returned an error: (400) Bad Request.'
每次。 我发出了大约200000个请求,这些请求都可以作为测试正常工作,从那时起,我发出的每个请求都导致了此异常。 但是,我可以在浏览器中查看该URL。 我是否已超过Google允许单个用户在24小时内发出的请求数量? 他们有限制吗? 如果有一个限制,是否有办法解决?
该错误可能是我的,所以这是我的代码:
Image[,] images = new Image[26, 13];
Parallel.For(0, 26, x => {
Parallel.For(0, 13, y => {
using (WebClient client = new WebClient())
images[x, y] = Image.FromStream(new MemoryStream(client.DownloadData(Get.TileURL(panoID, x, y))));
});
});
Get.TileUrl:
public static string TileURL(string panoID, int x, int y, int zoomLevel = 5)
{
return "http://cbk0.google.com/cbk?output=tile&panoid=" + panoID + "&zoom=" + zoomLevel + "&x=" + x + "&y=" + y;
}
我尝试捕获该异常,以查看它是否是一次性事件,但是对于每个单个请求,都会导致相同的异常。
这里是网络日志上面,看到的代码这里是当它在for循环标准运行的日志文件。
我尝试过的事情:
问题出在我正在喂的那种pano id上。 cbk0.google.com和maps.google.com都不能使用以CAoSLEFGMVFpcE
开头的全景图ID来显示图块,但是,这些全景图仍适用于Google记录的api。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.