I'm trying to parse the site - https://rentcar.gr/en/booking/cars as I understood in the developer panel, I must first set up a post and then get a request to get the desired page, but I ran into a problem in my opinion with cookies
This is screen from developer panel of this requests(post -> get)
This my code firstly a get page for get token and take cookies, then use this data for POST req and save cookies, then use this cookies for get req but get wrong content looking at it, it seems to me that this is the code for the main page of the site
from requests import Session
from bs4 import BeautifulSoup
api_url = "https://rentcar.gr/en/booking/cars"
work = Session()
req = work.get(api_url)
soup = BeautifulSoup(req.content, "html.parser")
token = soup.find('form').find('input').get('value')
data = {
'_token': token,
'pickUpLocation': '8',
'pickUpDate': '22-02-2024',
'pickUpTime': '10:00',
'dropOffLocation': '6',
'dropOffDate': '29-02-2024',
'dropOffTime': '10:00',
'driverAge': '25',
'carID': '0',
'minPickUpDate': '22-02-2024',
'minDropOffDate': '22-02-2024',
}
req = work.post(api_url, cookies=req.cookies, data=data)
soup = BeautifulSoup(
work.get(api_url, cookies=req.cookies).content, "html.parser"
)
for h3 in soup.select("h3.carname"):
print(f'{h3.text:<60}')
second Api give you a response in HTML format.