My task is to get a calendar of booking of apartments from the site pages https://www.dobovo.com/ . The site itself receives data from the post-request in json format when the page is loaded. When I send a similar request, I get the following error {'success': False, 'error': 'Method GET is not allowed'}
, although I post the request by the post method.
Interestingly, a few days ago I could get the data in the same way.
It's also funny that I can get this json from the terminal: curl -d "id=89740&date=2017-07-01" https://www.dobovo.com/dobovo/apt/ajax.php?action=getCalendar&lang=en
or wget --post-data="id=82731&date=2017-07-01" https://www.dobovo.com/dobovo/apt/ajax.php?action=getCalendar&lang=en
(id = 82731 is an example for one apartment)
My Python code:
from requests import post
def get_calendar(url):
ajax = 'http://www.dobovo.com/dobovo/apt/ajax.php?action=getCalendar&lang=en'
first_day_in_month = '2017-07-01'
id_ = url[-10:-5]
form_data = {
'id': id_,
'date': first_day_in_month
}
response = post(url=ajax, data=form_data)
return response.json()
url here is a link to a page with a calendar, like https://www.dobovo.com/zaporozhye-apartments/orchid-82731.html
Tell me, please, what am I doing wrong?