Capture embedded google map image with Python without using a browser

前端 未结 8 1148
心在旅途
心在旅途 2020-12-04 18:57

I have noticed that, from Google Maps page, you can get an \"embed\" link to put inside an iframe and load the map in a browser. (no news here)

The image size can be

8条回答
  •  北荒
    北荒 (楼主)
    2020-12-04 19:18

    The most simplest way to have the Google static map image captured/saved (as a png):

    import requests
    
    img = open('tmp.png','wb')
    img.write(requests.get('https://maps.googleapis.com/maps/api/staticmap?center=33.0456,131.3009&zoom=12&size=320x385&key=YOUR_API_KEY').content)
    img.close()
    

提交回复
热议问题