Some tips analog recording Python requests library browser behavior

The following are some of the voice of experience, regularly updated, you can look like oh.

Ignore ssl error

Some error causes the program to issue a certificate, the solution at the time of sending the request, verify = False parameters can take;

result = requests.get(burp0_url, headers=burp0_headers, verify=False)


Set up a proxy to requests

This feature is very useful, and sometimes want to simulate contracting browser, then set up a proxy, then intercept them, and by comparing the browser, you will be able to know that you and your browser contracting any difference.

proxies = {'http': 'http://localhost:8080', 'https': 'http://localhost:8080'}
result = requests.get(burp0_url, headers=burp0_headers, proxies=proxies, verify=False)


Jump encountered response to 302

302 requests encountered jump when it is the default jump, but not like a web browser cookie save, which would be wrong to jump to lead to a second page, the solution is to add allow_redirects = False parameters, which would not jump, step by step and setting parameters on the browser the same.

Requests allow_redirects default value is True.

requests.get(burp0_url, headers=burp0_headers, cookies=cookie1, allow_redirects=False)

Guess you like

Origin www.cnblogs.com/mysticbinary/p/12088268.html
Recommended