Answer the question
In order to leave comments, you need to log in
How to get https redirect link in get request?
I get a link (1), going to which there is a 5-second check, after which - a redirect to another link (2). Using the telethon library, I wrote the following code:
r = requests.get(url1, allow_redirects=True)
print(f'Чистая ссылка: {r.url}')
Answer the question
In order to leave comments, you need to log in
> jumping to which the 5 second check occurs
This means that the redirect is done by means of JS, and not through HTTP 3XX response codes.
requests can only handle the last option, since it doesn't emulate the entire browser.
Theoretically, the correct link can be scratched out of the contents of the downloaded page, but in practice it is not a fact - most likely, the verification page was entered just to protect against scripts like yours.
You can play around with the selenium package, it allows you to pretend to be a full-fledged browser - suddenly it works out.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question