TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Python Requests: HTTP for Humans

397 pointsby frznover 13 years ago
Requests is an ISC Licensed HTTP library, written in Python, for human beings.<p>Requests allow you to send HEAD, GET, POST, PUT, PATCH, and DELETE HTTP requests. You can add headers, form data, multipart files, and parameters with simple Python dictionaries, and access the response data in the same way. It’s powered by urllib2, but it does all the hard work and crazy hacks for you.

25 comments

old-greggover 13 years ago
Absolutely my favourite recent development in the Python world. I won't be mistaken if I say that many of us have built half-arse versions of this on top of urllib(2) multiple times in the past. :-)<p>The support for keep-alive is particularly welcome, huge kudos to the author.<p>Question to users of other languages: do equivalents exist for PHP, Perl, C# or Java? Ruby folks rave about restclient, but is there anything else?
评论 #3095526 未加载
评论 #3095392 未加载
评论 #3095226 未加载
评论 #3095196 未加载
评论 #3096042 未加载
评论 #3095252 未加载
评论 #3096991 未加载
DanielRibeiroover 13 years ago
Discussion from the two month old submission: <a href="http://news.ycombinator.com/item?id=2882301" rel="nofollow">http://news.ycombinator.com/item?id=2882301</a>
megaman821over 13 years ago
This looks so nice. Is there any upcoming support for HTTP caching? I know it is not the easiest thing to do because you will probably need to make several cache backends (file, db, memcached, redis, etc.) to keep everyone happy.<p>Also I couldn't tell if there is keep-alive support, is there?
评论 #3095016 未加载
vidarover 13 years ago
What is the timeline for v0.7? Desperately need the asynchronous stuff!
评论 #3095264 未加载
efsavageover 13 years ago
I don't mean to badmouth Requests or Python in general, it certainly looks like an improvement, but can anyone enlighten me as to why an API that wraps an HTTP request with concise methods is #1 on HN, twice? This looks more like a good answer to SO question than "news".<p>This looks like all the other wrapper methods you spend 5 minutes doing, once, when you start a new codebase?
评论 #3095479 未加载
评论 #3096494 未加载
评论 #3096477 未加载
评论 #3095689 未加载
basculeover 13 years ago
I just started working on a similar library for Ruby:<p><a href="https://github.com/tarcieri/http" rel="nofollow">https://github.com/tarcieri/http</a>
mp3tricordover 13 years ago
Looks like Python got something similar to Perl's LWP <a href="https://metacpan.org/module/LWP" rel="nofollow">https://metacpan.org/module/LWP</a>
评论 #3095373 未加载
pchiversover 13 years ago
Link to previous discussion on HN:<p><a href="http://news.ycombinator.com/item?id=2882301" rel="nofollow">http://news.ycombinator.com/item?id=2882301</a>
d0vsover 13 years ago
Unfortunately, no Python 3 support
评论 #3094954 未加载
评论 #3095248 未加载
jacoblylesover 13 years ago
Finally, an easy way to make POST requests from Python
artlogicover 13 years ago
Forgive me if I've missed this, but does this library have support for multipart/form-data POSTing? That's a capability in the python library that's sorely missing - especially in 2.X.
评论 #3096490 未加载
leonderijkeover 13 years ago
I'm using it in a project I'm working on. It's really easy to use!
objectifiedover 13 years ago
Although Requests looks very nice, I've wondered why most people wouldn't simply use pycurl - <a href="http://pycurl.sourceforge.net/" rel="nofollow">http://pycurl.sourceforge.net/</a> ? It's stable and you get all the power that cURL has (which is a lot), and the API is fairly simple - although maybe not as pythonic as the Requests API is.<p>On a side note: last time I checked urllib2 (which actually drives Requests) could not do SSL requests over a proxy, which gave me the feeling that this implementation still isn't very mature.
评论 #3099811 未加载
josephturnipover 13 years ago
I love Requests, but it would be really nice to have some Python libraries with cert-verified SSL support. I've hacked SSL support on top of urllib2 for my projects at work (<a href="https://github.com/josephturnerjr/urllib2.VerifiedHTTPS" rel="nofollow">https://github.com/josephturnerjr/urllib2.VerifiedHTTPS</a>), but it'd be really nice if libraries started prioritizing secure communications as a first-order requirement.
评论 #3097016 未加载
seanmcqover 13 years ago
I note that you call gevent.monkey.patch_all() in async.<p>I'm still fairly new to gevent and I'm curious if others consider this good style for a library?
评论 #3095710 未加载
jsilenceover 13 years ago
Trying to use the requests module yields:<p><pre><code> File "/usr/lib/python2.6/cookielib.py", line 38, in &#60;module&#62; from calendar import timegm</code></pre> ImportError: cannot import name timegm<p>for me.<p>On two different machines, one OSX SL with Python 2.6 from MacPorts and the other Ubuntu 10.04.3 LTS with Python 2.6 via aptitude.<p>Can not find any solution for this via Google and its siblings.<p>I'm stuck :(<p>-jsl
voyvfover 13 years ago
I love this API, and it looks like the dev version is getting even better. r.iter_content is exactly what I needed! :D
nemoniacover 13 years ago
Excellent library but they need to fix this piece of misinformation: "A project that is released as GPL cannot be used in any commercial product without the product itself also being offered as open source."<p>This is false. A project released as GPL can also be released on another (commercial) license.
评论 #3098714 未加载
pbreitover 13 years ago
If Python is going to include urllib or urllib2 in the standard distro, why not make it good? Http is foundational to (web) programming. I am shocked at how poor the standard httpclient implementations are in most environments.
dannyobrienover 13 years ago
Oh, what I would give for a "mechanize for humans" built on this! I love mechanize, but I dream of not having to go back to its one page documentation and the source code every time I want to do something.
abrahamover 13 years ago
There is also an addon for Requests that lets you make OAuth requests: <a href="https://github.com/maraujop/requests-oauth-hook" rel="nofollow">https://github.com/maraujop/requests-oauth-hook</a>
16sover 13 years ago
How does this compare (feature wise) to the poster library? Are they about the same? I've used poster some, but not requests... I'll have to try it now. Just curious how it compares to poster.
评论 #3099820 未加载
评论 #3096487 未加载
cjusover 13 years ago
Given that there are a great deal of service APIs in the wild this is going to lower the barrier of entry for many less experienced developers looking to prototype their ideas.
jrydbergover 13 years ago
It would be nice with something similar for Twisted.
dreamdu5tover 13 years ago
What's with the "for human beings" phrase? Is that a way of saying the software is easy?
评论 #3095322 未加载
评论 #3095065 未加载
评论 #3095078 未加载
评论 #3095278 未加载