Home > database >  Python requests - Website says missing data, what data is missing?
Python requests - Website says missing data, what data is missing?

Time:03-10

I'm trying to send a post request to a website named www.bazos.sk . This website is a advertisement website, where you can upload your stuff to sell (it's like ebay, but much smaller). After the post, the website returns the next HTML of the redirection. If I upload a ad by hand, i get the HTML that says it was successfully uploaded, but if I post it, i get return code 200 (so it was successfully sent), but the HTML says (in slovak) that it was not uploaded. I think something is missing from my code (i'm trying to get what is the missing thing, but I can't).

I tested, I can remove advertisements easily, but as you can see, I can't upload them.

This is my code (All presonal datas needed are fake in this code):

import requests


url = 'https://deti.bazos.sk/insert.php'
data = {
    'category': '122',
    'nadpis': 'test', #nadpis = title
    'popis': 'test', #popis = description
    'cena': '1', #cena = price
    'cenavyber': '1', #cenavyber = choosable price
    'lokalita': '03403', #lokalita = where is the advertisement located
    'jmeno': 'XXXXX', #jmeno = name
    'telefoni': '8374827543', #telefoni = phone number
    'maili': '[email protected]', #maili = mail
    'heslobazar': 'XXXXXXXX20', #heslobazar = password
    'werwe': 'fsfwereg', 
    'Submit': 'Odoslať'
}


print("Processing...")

response = requests.post(url, data=data)
print(response.status_code, response.reason)
print(response.text)


input("Press [ENTER] to quit")

I tried with replacing data=data to json=data, nothing. And the url is right, because as you can see, on the beginning of the post the url is www.bazos.sk but in the code it is deti.bazos.sk , the reason for this in short: This website has multiple categories, and has a different url name for each category.

I add pictures too of the network datas:

  1. https://i.stack.imgur.com/QqTeN.png
  2. https://i.stack.imgur.com/uVcMi.png
  3. https://i.stack.imgur.com/bcMRC.png
  4. https://i.stack.imgur.com/VODIj.png
  5. https://i.stack.imgur.com/8PKv6.png

CodePudding user response:

Adding Authentication,API specific Cookies to your requests.

  • Related