total = 1
page = 1
for i in range(total + 1):
response = requests.get(f"https://www.avito.ru/moskva/avtomobili?p={page}&radius=100")
if response.status_code == 200:
total = total + i
page = page + 1
print("Working...")
else:
print("Всего страниц: ", total)
STATUS_OK = 200
url = 'https://www.avito.ru/moskva/avtomobili?p={page}&radius=100'
page = 1
status = 200
while status == STATUS_OK:
response = requests.get(url.format(page=page))
if response.status_code == STATUS_OK:
page += 1
print("Working...")
else:
status = response.status_code
print("Всего страниц: ", page)