我尝试使用Bing Maps API下载静态地图。当我从Chrome加载网址时,它可以正常工作,但是当我尝试从Linux进行wget转换时,我收到了Auth Failed错误。
网址相同,但出于某种原因,Bing阻止了来自Linux的调用?
这是我尝试过的命令:
wget -O map.png http://dev.virtualearth.net/REST/V1/Imagery/Map/Road/...
curl -O map.png http://dev.virtualearth.net/REST/V1/Imagery/Map/Road/...
错误:
Resolving dev.virtualearth.net (dev.virtualearth.net)... 131.253.14.8
Connecting to dev.virtualearth.net (dev.virtualearth.net)|131.253.14.8|:80... connected.
HTTP request sent, awaiting response... 401 Unauthorized
Username/Password Authentication Failed.
--2016-10-24 15:42:30-- http://dev.virtualearth.net/REST/V1/Imagery/Map/Road/.../12?mapSize=340,500
Reusing existing connection to dev.virtualearth.net:80.
HTTP request sent, awaiting response... 401 Unauthorized
Username/Password Authentication Failed.
我不确定它是否与密钥类型有任何关系,我已经尝试了几个从公共网站到开发/测试,但仍然没有工作。
答案 0 :(得分:1)
需要使用引号将URL包装起来(因为需要转义的查询字符串中包含&
符号):
wget 'http://dev.virtualearth.net/REST/V1/Imagery/Map/Road/...'
<强>实施例强>
通过wget
:
wget -O map.jpg 'http://dev.virtualearth.net/REST/V1/Imagery/Map/Road/Bellevue%20Washington?mapLayer=TrafficFlow&key=<key>'
通过curl:
curl -o map.jpg 'http://dev.virtualearth.net/REST/V1/Imagery/Map/Road/Bellevue%20Washington?mapLayer=TrafficFlow&key=<key>'
已在Ubuntu 16.04下验证