V
V
Vovan20052020-02-04 18:38:49
Python
Vovan2005, 2020-02-04 18:38:49

How to avoid redirects when scraping a site?

I am parsing a website in python using BF4. All pages except one are parsed without problems. But the problematic page cannot be read due to the fact that after accessing this page, it redirects me to the main one.
Is there a script for this? And how in theory to get around this redirect?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander, 2020-02-04
@cashncarry

In short - no way)
The very essence of the redirect is this. A page is a link to another page
But if you need to catch redirects, you can use "status_code"

r = requests.get(url)
if r.status_code in [301, 302]:
    #  переадресация

If you are using requests see this example

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question