Skip to content

Instantly share code, notes, and snippets.

@Jiali-Qi
Created September 9, 2019 17:06
Show Gist options
  • Save Jiali-Qi/b1899a6054e2940556e587c79c74e593 to your computer and use it in GitHub Desktop.
Save Jiali-Qi/b1899a6054e2940556e587c79c74e593 to your computer and use it in GitHub Desktop.
My 1st homework
Created on Mon Sep 9 11:08:53 2019
@author: qijia
"""
import requests
# A Google search for the term "Tim Berners-Lee".
r1 = requests.get('https://www.google.com/search?q=tim+berners-lee')
print (r1.content)
print (r1.status_code)
print (r1.headers)
# A POST request to a website that does not accept POST requests.
payload = {'key1':'value1', 'key2': 'value2'}
r2 = requests.post("http://www.google.com", data=payload)
print (r2.content)
print (r2.status_code)
print (r2.headers)
# A request to a URL that does not exist.
r3 = requests.get('http://www.jiali.com')
print (r3.content)
print (r3.status_code)
print (r3.headers)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment