Skip to content
Myr

switch streaming requests to httpbin

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

authored by Kenneth Reitz · committed by Kenneth Reitz · parent c0baec1 · Browse files · 1 file+5 added−12 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+5 added−12 removed

  • other:+5 added−12 removed

1 file+5 added−12 removed

modified:docs/user/advanced.rst+5 added-12 removed
274 unmodified lines
275APIs such as the `Twitter Streaming API <https://dev.twitter.com/docs/streaming-api>`_.276277To use the Twitter Streaming API to track the keyword "requests"::278279 import requests279 import json281 from requests_oauthlib import OAuth1280 import requests281283 app_key = 'YOUR_APP_KEY'284 app_secret = 'YOUR_APP_SECRET'285 oauth_token = 'USER_OAUTH_TOKEN'286 oauth_token_secret = 'USER_OAUTH_TOKEN_SECRET'282 r = requests.post('http://httpbin.org/stream/20', stream=True)283288 auth = OAuth1(app_key, app_secret, oauth_token, oauth_token_secret)289290 r = requests.post('https://stream.twitter.com/1.1/statuses/filter.json',291 data={'track': 'requests'}, auth=auth, stream=True)292284 for line in r.iter_lines():285294 if line: # filter out keep-alive new lines286 # filter out keep-alive new lines287 if line:288 print json.loads(line)289290291Proxies
285 unmodified lines