Python USES the requests library to simulate a simple example of logging in and fetching data

  • 2020-04-02 13:48:05
  • OfStack

If you're still struggling with python's urllib and urlibs, cookielib, or are still struggling with python's mock logins and crawls, check out our recommendations for python's essential tool for mock logins!

This is also python's recommended HTTP client library:

This article with a simulation login example to illustrate, as for the collection of everyone please play.

The code is simple, mostly to show the simplicity of python's requests library, as follows:


s = requests.session()
data = {'user':' The user name ','passdw':' password '}
#post  Change to the address of the login, 
res=s.post('http://www.xxx.net/index.php?action=login',data);
# Instead, grab the address 
s.get('http://www.xxx.net/archives/155/');

Look! With just four lines of code, you can simulate login.


Related articles: