Bing REST HTTPError(req.full_url,code,msg,hdrs,fp)

问题描述 投票:0回答:1

我需要获取许多地址的纬度和经度位置,大约100k +。但是,按照我的代码的工作方式,我认为Bing阻止了我,因为他们认为我是垃圾邮件机器人或其他东西?我不确定错误是什么意思。有什么办法可以解决此问题?

for i in listAddresses:
    url = "http://dev.virtualearth.net/REST/v1/Locations/US/" + i + "?o=xml&key=" + subscriptionKey

    # original code but I got the HTTPError
    # page = urllib.request.urlopen(url)
    # stringPage = page.read().decode('utf-8')

    # some code I found online. Still returns the same error
    req = Request(url, headers={'User-Agent': 'Mozilla/5.0'})
    stringPage = urlopen(req).read().decode('utf-8')

    # really bad/ basic way of getting the latitude and longitude from the xml return
    lat = re.findall(r'<Latitude>(.*?)</Latitude>', stringPage)[0]
    long = re.findall(r'<Longitude>(.*?)</Longitude>', stringPage)[0]
    address = i.replace("%20", " ")  

    location.append(address)
    location.append(lat)
    location.append(long)  

File "C:\Users\...\lib\urllib\request.py", line 649, in http_error_default
    raise HTTPError(req.full_url, code, msg, hdrs, fp) 
python urllib bing-maps
1个回答
0
投票

[Bing很可能会“阻止”您。它不一定认为您是“垃圾邮件机器人”,它只是Bing Maps REST API的免费“基本”帐户的一个强加限制(但也用于防止垃圾邮件)。

Bing每秒最多允许5个请求,免费帐户每年总共125,000个请求,付费产品最多可以每秒50个请求,还有更多请求。您可以在此处查看更多信息:https://www.microsoft.com/en-us/maps/licensing/options

不幸的是,没有免费的午餐。

© www.soinside.com 2019 - 2024. All rights reserved.