I am trying to use the Twitter streaming API using Python requests.
The documentation has a simple example :
import requests
import json
r = requests.post('https://stream.twitter.com/1/statuses/filter.json',
data={'track': 'requests'}, auth=('username', 'password'))
for line in r.iter_lines():
if line:
print json.loads(line)
When I do this, the call requests.post()never returns. I experimented and proved that it definitely connects to Twitter and receives data from the API. However, instead of returning a response object, it just sits there, consuming as much data as twitter sends. Judging by the code above, I would expect it to requests.post()return a response object with an open Twitter connection, and I could continue to get the results in real time.
( , , Twitter , Twitter , . r.content , .)
- , requests.post . , , , , . .
:
- Python 2.7
- Ubuntu 11.04
- 0.14.0