linux - 如何在 Linux 中下载 Bing 静态 map

标签 linux curl bing-maps

我正在尝试使用 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/

相关文章:

c - printf 函数行为和转换

c# - 如何将多个 (n) 多边形绑定(bind)到 Bing map 控件

c# - 如何用BingMap计算 map 4个角(边)的坐标?

mysql - 如何允许用户在 Rails 中安排重复的 cron 作业

c - 了解多核 SMP 系统

http - curl 输出不重定向到文件

php - 循环中的 cURL 请求有时根本不返回任何内容

javascript - Bing map CSS 位置 :fixed InfoBox issues

linux - 对目录中的文件进行排序,然后打印内容

curl - Google Analytics API和用户定义的变量