S
S
sidorikv2021-09-27 16:14:12
Python
sidorikv, 2021-09-27 16:14:12

Why can't work with while?

I welcome everyone.
There is this code:

def account_worker(auth_data):

  response = 0
  session = requests.session()

  auth_link = 'some.site.ru'
  user_agent = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/93.0.4577.82 
  Safari/537.36'

  headers = {
    'Accept': '*/*',
    'Accept-Encoding': 'gzip, deflate, br',
    'Accept-language': 'ru-RU,ru;q=0.9,en-US;q=0.8,en;q=0.7',
    'Content-Type': 'application/x-www-form-urlencoded',
    'Referer': 'some.site.ru',
    'sec-fetch-mode': 'navigate',
    'origin': 'some.site.ru',
    'sec-ch-ua': '"Google Chrome";v="93", " Not;A Brand";v="99", "Chromium";v="93"',
    'host': 'some.site.ru',
    'sec-ch-ua-platform': '"Windows"',
    'user-agent': user_agent,
    'sec-fetch-site': 'same-origin',
    'sec-fetch-site': 'same-origin',
    'sec-ch-ua-mobile': '?0',
    'sec-fetch-user': '?1',
    'upgrade-insecure-requests': '1',
    'sec-fetch-dest': 'document'
  }
  data = auth_data

  while response != 200:
    response = session.post(auth_link, data=data, headers=headers)
    print(response)


Everything seems to be very simple. Make a request, if you received a response not 200, then continue to make a request until you get a response of 200. But for some reason, only one request is made. Help, I've already tried everything

UPD: I get a 504 request, it still runs once

Answer the question

In order to leave comments, you need to log in

1 answer(s)
G
galaxy, 2021-09-27
@sidorikv

And who told you that session.post() returns a number?
https://docs.python-requests.org/en/latest/api/#re...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question