浙江省高等学校教师教育理论培训

微信搜索“毛凌志岗前心得”小程序

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

Requests: HTTP for Humans — Requests 0.11.1 documentation

Requests: HTTP for Humans

Release v0.11.1. (Installation)

Requests is an ISC Licensed HTTP library, written in Python, for human beings.

Python’s standard urllib2 module provides most of
the HTTP capabilities you need, but the API is thoroughly broken.
It was built for a different time — and a different web. It requires an enormous amount of work (even method overrides) to perform the simplest of tasks.

Things shouldn’t be this way. Not in Python.

>>> r = requests.get('https://api.github.com', auth=('user', 'pass'))
>>> r.status_code
204
>>> r.headers['content-type']
'application/json'
>>> r.text
...

See the same code, without Requests.

Requests takes all of the work out of Python HTTP/1.1 — making your integration with web services seamless. There’s no need to manually add query strings to your URLs, or to form-encode your POST data. Keep-alive and HTTP connection pooling are 100% automatic, powered by urllib3, which is embedded within Requests.

posted on 2012-04-01 22:05  lexus  阅读(325)  评论(0)    收藏  举报