Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

Session maintains a session

Shulou Source: shulou.com Published: 2022-06-03 08:05:41 09月23日 Update

Requests.get ('http://httpbin.org/cookies/set?number=123456')

Requests.get ('http://httpbin.org/cookies')

The above two request requests (whether get or post) are equivalent to opening the windows of two browsers. They are irrelevant.

After logging in to a system, if you need to do something in the login state, how do you maintain the session?

S=requests.Session ()

Url1=' http://127.0.0.1/wordpress/wp-login.php' data1= {'log':'xxxx','pwd':'xxxxxx'}

# Login

R1=s.post (url1,data=data1)

Print (r1.url)

# you need to be logged in to complete the operation

Url2=' http://127.0.0.1/wordpress/wp-admin/user-new.php'

Data2= {'user_login':'test1','email':'1234567@163.com','createuser':' add user'}

R2=s.post (url2,data=data2)

Tags: Login status irrelevant two browser user system or browsing Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno OPPO Reno Shulou Information Shulou Tech Info Xiaomi Microsoft