Last active
May 4, 2019 17:01
-
-
Save joeface/ba23c49ab3b1ef0d23386c96168276e2 to your computer and use it in GitHub Desktop.
Python requests lib example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
# Retrieving Vladimir Putin's interviews from Kremlin website | |
response = requests.get('http://en.kremlin.ru/search', params={'query': 'interview'}, timeout=40) | |
# Checking response status code | |
if response.status_code == requests.codes.ok: | |
# Output response content as a string | |
print response.text | |
else: | |
# Status code is not 200 | |
print 'Error occured' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment