Skip to content
Myr

Add Twitter Streaming API example to Advanced Usage docs

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Jason Emerick · committed by Jason Emerick · parent c910b95 · Browse files · 1 file+21 added−0 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+21 added−0 removed

  • other:+21 added−0 removed

1 file+21 added−0 removed

modified:docs/user/advanced.rst+21 added
241 unmodified lines
242 >>> requests.get('http://pizzabin.org/admin', auth=PizzaAuth('kenneth'))243 <Response [200]>244245246Streaming Requests247------------------248249With ``requests.Response.iter_lines()`` you can easily iterate over streaming 250APIs such as the `Twitter Streaming API <https://dev.twitter.com/docs/streaming-api>`_.251252To use the Twitter Streaming API to track the keyword "requests":253254::255256 import requests257 import json258259 r = requests.post('https://stream.twitter.com/1/statuses/filter.json',260 data={'track': 'requests'}, auth=('username', 'password'))261262 for line in r.iter_lines():263 if line: # filter out keep-alive new lines264 print json.loads(line)265266267Verbose Logging268---------------269270If you want to get a good look at what HTTP requests are being sent
8 unmodified lines