A
A
Alexander Katunin2022-01-20 20:56:01
Python
Alexander Katunin, 2022-01-20 20:56:01

Problem with requests. How to fix an infinite get request?

With a normal get request, it works fine:

import requests
url = 'https://www.versace.ru'
response = requests.get(url=url)

But, when the get request gets into the loop, it starts an infinite request...
import requests
r = 0
while r<2:
    url = 'https://www.versace.ru'
    response = requests.get(url=url)
    r += 1

It is with this site that there is an endless request. Specified both headers and proxies, nothing...
Doesn't work with for and while loops. Who knows, tell me, please, how can I solve this?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dr. Bacon, 2022-01-20
@bacon

An infinite request usually turns out if there is an except inside that silences errors and because of which the r increment does not occur, you didn’t show us all the code, did you?
And instead, it's better to use and with a successful response, do break while r<2:for _ in range(2)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question