Why does the site not respond to post. requests?

Question:

Warning! I am not from English and ask on Eng Stack because on Stack of my county all ignore me

I have the code what will send an request to site for add an community group to list, but after authorization with their API and send requests site answer its code ‘200’ but nothing is change, dose someone know how to change this?

header = {
    "User-Agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) snap Chromium/81.0.4044.113 Chrome/81.0.4044.113 Safari/537.36"
}

with requests.Session() as s: # authorization by sute API
    response = s.get(f'http://likest.ru/api/users.login?authname={vk_id}')
    print(f'Для авторзиациия вам необходимо поставить отметку "лайк" на фото: {response.json()["like_like"]}') # for autorization u need to like this photo
    ender = input('Нажмите [ENTER]') # Press [ENTER]
    response = s.get(f'http://likest.ru/api/users.login?authname={vk_id}&like_id={response.json()["like_id"]}')
    print(response.json()['status'])
    for link in data_selected: # send request
        requests = s.post('https://likest.ru/groups/add',
                          headers=header,
                          data={
                              "link": link,
                              "reward": reward,
                              "amount": amount,
                              'sex': '0',
                              'country': "0",
                              'age_min': "0",
                              'age_max': "255",
                              'friends_min': "0",
                              "lim_5": lim_5,
                              "lim_30": lim_30,
                              "lim_60": lim_60,
                              'sleepy_factor': "0",
                              '_triggering_element_name': "op",
                              '_triggering_element_value': "С+правилами+согласен,+заказать"
                          },
                          )
Asked By: Antony Tona

||

Answers:

Since you are handling the session manually you create requests through requests.Request and prepare them before sending them via the session. Here’s an example

r = requests.Request("POST",f'http://likest.ru/api/users.login?authname={vk_id}&like_id={response.json()["like_id"]}')

req = r.prepare()
#spawn sesssion
s = requests.Session()
s.send(req)

You could also just use requests.get/requests.post instead

#equivalent to my above example
r = requests.post(f'http://likest.ru/api/users.login?authname={vk_id}&like_id={response.json()["like_id"]}')
Answered By: Nathan Mathews
Categories: questions Tags: , , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.