我正在尝试使用 Bing Maps API 下载静态 map 。当我从 Chrome 加载 URL 时它有效,但是当我尝试从 Linux curl 到 wget 时,我收到 Auth Failed 错误。
URL 相同但出于某种原因 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.
我不确定它是否与 key 类型有关,我已经尝试了从公共(public)网站到开发/测试的几种方法,但仍然没有用。
最佳答案
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>'
Have been verified under Ubuntu 16.04
关于linux - 如何在 Linux 中下载 Bing 静态 map ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40228781/