Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

python requests-session for websites with login

# import requests module
import requests
 
# create a session object
s = requests.Session()
 
# set username and password
s.auth = ('user', 'pass')
 
# update headers
s.headers.update({'x-test': 'true'})
 
# both 'x-test' and 'x-test2' are sent
s.get('https://httpbin.org / headers', headers ={'x-test2': 'true'})
 
# print object
print(s)
Comment

python requests login session

s = requests.Session()
Comment

python requests-session for websites wihout login

# import requests module
import requests
 
# create a session object
s = requests.Session()
 
# make a get request
s.get('https://httpbin.org / cookies / set / sessioncookie / 123456789')
 
# again make a get request
r = s.get('https://httpbin.org / cookies')
 
# check if cookie is still set
print(r.text)
Comment

PREVIOUS NEXT
Code Example
Python :: ipaddress in python 
Python :: stutter function in python 
Python :: Flask command db migrate 
Python :: how to open folder in python 
Python :: python gui 
Python :: python webbrowser module 
Python :: python new date 
Python :: dataframe fill nan with mode 
Python :: maximum element in dataframe row 
Python :: get url param in get django rest 
Python :: break while loop python 
Python :: hugingface ner 
Python :: hover show all Y values in Bokeh 
Python :: csv file sort python 
Python :: visit website with python 
Python :: add python to path 
Python :: Selecting subset of columns with pandas 
Python :: django optional path parameter 
Python :: python constant 
Python :: python to c# converter 
Python :: flask docs 
Python :: bitwise operators python 
Python :: how to add captcha in django forms 
Python :: how to convert python to exe 
Python :: how to make a random int in python 
Python :: tkinter canvas text size 
Python :: convex hull python 
Python :: Get request using python requests-html module 
Python :: df sort by column names 
Python :: len(sys.argv) == 2 
ADD CONTENT
Topic
Content
Source link
Name
5+8 =