我是Python的新手(也是编程的新手),非常感谢大家的帮助。
如何使用下面的示例链接通过Python下载所提供的信息。
板卡{https://url.com/InfoService/GetFlightByFlightNum?board=}&flightNum={FLIGHTNUM}
方法: GET
谢谢
发布于 2013-04-03 07:20:59
从python访问APIs的最简单方法是使用requests库。
您可以使用pip install requests快速安装它
然后,您可以对您的示例执行此操作:
import requests
payload = {'board': {BOARD}, 'flightNum': {FLIGHTNUM}}
r = requests.get('https://url.com/InfoService/GetFlightByFlightNum', params=payload)
# print the response result
print r.text发布于 2013-04-03 07:11:31
您可以使用内置库urllib2。
Python2文档:http://docs.python.org/2/library/urllib2.html
Python3文档:http://docs.python.org/3.1/howto/urllib2.html
https://stackoverflow.com/questions/15775945
复制相似问题