首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >似乎不能让我的google地图数据抓取工作

似乎不能让我的google地图数据抓取工作
EN

Stack Overflow用户
提问于 2019-09-25 15:36:39
回答 1查看 125关注 0票数 0

当我运行这段代码时,我的spyder终端没有完成,在点击enter几次之后,我得到了以下错误消息:

{‘目的地_地址’:[],'error_message':‘您必须使用一个API密钥来验证每个对Google平台API的请求。

这是我的密码:

代码语言:javascript
复制
def scrape_gmaps_data():

    #import required libraries
    import requests, json

    #enter your api key here
    api_key = 'I tried with my actual API key'

    #take source as input
    source = input()

    #take destination as input
    dest = input()

    #url variable store url
    url = 'https://maps.googleapis.com/maps/api/distancematrix/json?'

    #get method of requests module
    #return response object

    r = requests.get(url + 'origins = ' + source + '&destinations = ' + dest + '&key = ' + api_key)

    #json method of response object
    #return json format result

    x = r.json()

    #by default driving mode considered

    #print value of x
    print(x)

scrape_gmaps_data()
EN

回答 1

Stack Overflow用户

发布于 2019-09-25 16:28:15

你必须移除“=”周围的空格。

比如:

代码语言:javascript
复制
r = requests.get(url + 'origins=' + source + '&destinations=' + dest + '&key=' + api_key)

希望能帮上忙。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/58102024

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档