P
P
perfecti0nist2016-03-04 14:45:55
Python
perfecti0nist, 2016-03-04 14:45:55

How to authorize in a corporate environment through a script?

I need to download several pages on the corporate website for analysis, but I can't log in. The server always responds with 401. I
use a standard request:

r = requests.get('https://example.com', auth=('user', 'pass'))

How to log in correctly?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
A
Alexey Ukolov, 2016-03-04
@alexey-m-ukolov

How to log in correctly?
The answer to this question is known only to the one who wrote this site.
Open the Chrome console, look in the Network panel for requests (you need to set the "Preserve log" flag) and make a sequence: what, where and in what order you need to send in order to get the coveted cookie.

A
Andrey Shubin, 2016-03-04
@idegree

from requests.auth import HTTPBasicAuth

r = requests.post('https://example.com, auth=HTTPBasicAuth('user', 'pass'))

There are different types of authorization. Try to look at the page headers which authorization you need to use.

V
Vladimir Kuts, 2016-03-04
@fox_12

Watch outgoing / incoming requests with a browser, and in the script in the headers form the same ones.
For example, the User-Agent can be checked on the server side

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question