Created
January 15, 2015 18:33
-
-
Save vik-y/e237eb9cb9633c8b28a3 to your computer and use it in GitHub Desktop.
Python Web Requests
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 | |
#We often have to automate some task, using requests library can be pretty easy as we | |
#Dont have to bother about the headers which we send along with our call and lets us do things fast. | |
''' | |
Functions to send Simple get and post request along with payload | |
payload is a dictionary | |
cookie is also a dictionary of key value pair | |
''' | |
def get_request(payload, url, cookie): | |
r = requests.get(url, params=payload, cookies = cookie) | |
return r; # r.text gives exact text/html/json response which came from the server | |
def post_request(payload, url, cookie): | |
r = requests.post(url, data=payload, cookies = cookie) | |
return r; # r.text gives exact text/html/json response which came from the server | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment