使用Python3通过API接口获取代理IP的代码样例
站大爷
官方
2024-01-12
11275 浏览
温馨提示:
1. 此样例支持 Python 2.6—2.7以及3.3以上
2. requests不是python原生库,需要安装才能使用: pip install requests
3. 此样例为json格式,在生成API提取链接时注意选择JSON格式
import requests
# API接口,返回格式为json
api_url = "http://www.***.com/ShortProxy/GetIP/?api=1234567890&akey=8a17ca305f683620&count=10×pan=3&type=3"
# API接口返回的ip
proxy_ip = requests.get(api_url).json()['data']['proxy_list']