首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在Python中使用特定API

在Python中使用特定API
EN

Stack Overflow用户
提问于 2013-04-03 06:59:14
回答 2查看 64关注 0票数 0

我是Python的新手(也是编程的新手),非常感谢大家的帮助。

如何使用下面的示例链接通过Python下载所提供的信息。

板卡{https://url.com/InfoService/GetFlightByFlightNum?board=}&flightNum={FLIGHTNUM}

方法: GET

谢谢

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2013-04-03 07:20:59

从python访问APIs的最简单方法是使用requests库。

您可以使用pip install requests快速安装它

然后,您可以对您的示例执行此操作:

代码语言:javascript
复制
import requests

payload = {'board': {BOARD}, 'flightNum': {FLIGHTNUM}}
r = requests.get('https://url.com/InfoService/GetFlightByFlightNum', params=payload)

# print the response result
print r.text
票数 1
EN

Stack Overflow用户

发布于 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

以下是一些示例:How do I download a file over HTTP using Python?

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/15775945

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档