python爬虫之百度API调用方法
作者:jingxian 时间:2021-11-18 17:17:13
调用百度API获取经纬度信息。
import requests
import json
address = input('请输入地点:')
par = {'address': address, 'key': 'cb649a25c1f81c1451adbeca73623251'}
url = 'http://restapi.amap.com/v3/geocode/geo'
res = requests.get(url, par)
json_data = json.loads(res.text)
geo = json_data['geocodes'][0]['location']
longitude = geo.split(',')[0]
latitude = geo.split(',')[1]
print(longitude,latitude)
其实调用API不难,这里是get方法,参数是地址和key,这个key是我在网上找的,应该是可以用的。
运行下代码。
然后糗事百科的地址处理后,调用API即可获得经纬度,然后利用个人BDP即可完成该图。
标签:python,爬虫,百度API
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
python用来获得图片exif信息的库实例分析
2022-07-16 12:29:38
Python ValueError: invalid literal for int() with base 10 实用解决方法
2023-06-18 17:00:40
python使用datetime模块计算各种时间间隔的方法
2021-11-28 05:31:35
Python3.6安装及引入Requests库的实现方法
2022-06-12 16:55:46
![](https://img.aspxhome.com/file/2023/4/120644_0s.jpg)
tensorflow图像裁剪进行数据增强操作
2023-06-23 14:33:20
![](https://img.aspxhome.com/file/2023/3/60713_0s.jpg)
python模仿网页版微信发送消息功能
2022-01-15 00:12:54
![](https://img.aspxhome.com/file/2023/5/110465_0s.jpg)
python 在mysql中插入null空值的操作
2022-09-24 09:48:40
![](https://img.aspxhome.com/file/2023/8/67888_0s.jpg)
Python爬虫利用多线程爬取 LOL 高清壁纸
2023-02-10 15:07:25
![](https://img.aspxhome.com/file/2023/6/127076_0s.webp)
Python抽象类应用详情
2022-03-24 17:41:13
![](https://img.aspxhome.com/file/2023/9/99229_0s.png)
Mootools 1.2教程(3)——数组使用简介
2008-11-17 20:16:00
python登陆asp网站页面的实现代码
2021-01-20 00:03:31
Python基础知识方法重写+文件处理+异常处理
2022-09-20 06:43:43
![](https://img.aspxhome.com/file/2023/3/102753_0s.png)
python linecache读取行更新的实现
2021-01-26 01:33:06
asp如何制作一个小巧的购物车?
2010-07-07 12:25:00
零基础也能看懂的python内置csv模块教程
2023-01-06 14:03:16
![](https://img.aspxhome.com/file/2023/2/121692_0s.png)
从trim原型函数看js正则表达式的性能
2008-12-11 13:55:00
Django之第三方平台QQ授权登录的实现
2023-04-27 16:37:06
Access数据库出现0x80004005问题的解决方法
2008-11-28 14:25:00
用一个例子来认识innerText,innerHTML
2007-12-24 17:17:00
(X)HTML中最多余的元素标签
2008-06-15 15:48:00