Google map Api调用的卫星地图使用python的urllib包保存到本地磁盘,并报告错误

2024-06-16 18:11:10 发布

您现在位置:Python中文网/ 问答频道 /正文

我使用GoogleMap静态地图api获取卫星图像,并希望将其存储在本地硬盘中,但python得到了urllib.error.URLError: <urlopen error [WinError 10060]

这是我的代码,非常简单,谢谢

 import urllib
 import urllib.request as ur
 # picture back from Google Static Map Api
 img_src = 'http://maps.googleapis.com/maps/api/staticmap?scale=2&center=31.403874,115.998672&zoom=12&size=400x400&maptype=satellite&key=############'
 ur.urlretrieve(img_src, 'D:/G.png')

Tags: 图像importsrcapiimg地图静态error
1条回答
网友
1楼 · 发布于 2024-06-16 18:11:10

我认为您不想公开共享API密钥。这个很好用。 错误代码10060表示它无法连接到源。检查你的网络

import urllib.request

url = 'http://maps.googleapis.com/maps/api/staticmap?scale=2&center=31.403874,115.998672&zoom=12&size=400x400&maptype=satellite&key=#####'
urllib.request.urlretrieve(url, 'D:/map.png')

相关问题 更多 >