When I navigate to this site, input chassis number JTDJC123705048557 right next to Numéro de chassis and hit Consultation button, I get the required result which is displayed at the bottom of that page.
I'm trying to create a script using requests module to mimic the process I've detailed above. The script I've already created can produce the result accordingly only when I hardcode the value of PAGEDATA.
The value of PAGEDATA is the chassis number (decoded or something). The thing is when I use this chassis number JTDJC123705048557 in the inputbox, the value of PAGEDATA within params becomes 5243313432206F6E20436C69636B7E5243313236207E5243313330207E5243313334204A54444A433132333730353034383535377E in dev tools.
This is how I got success (using hardcoded value of pagedata from dev tools):
import re
import requests
link = 'https://www.mobilit.fgov.be/WebdivPub_FR/wmvpstv1_fr.jsp'
headers = {
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.0.0 Safari/537.36',
}
params = {
'SUBSESSIONID': '',
'DYNAMIC': 'DOREQUEST',
'NAME': 'CMV_WD_PBL01_CONSULT_STATUS',
'PSTEPID': '',
'WINDOWID': '',
'PAGEDATA': '5243313432206F6E20436C69636B7E5243313236207E5243313330207E5243313334204A54444A433132333730353034383535377E'
}
with requests.Session() as s:
s.headers.update(headers)
res = s.get(link)
session_id = res.url.split("=")[1]
params['SUBSESSIONID'] = session_id
params['PSTEPID'] = re.findall(r"pStepId=(.*?);",res.text)[0]
params['WINDOWID'] = re.findall(r"windowId=(.*?);",res.text)[0]
resp = s.get(link,params=params)
print(resp.text)
Question: how can I convert this chassis number
JTDJC123705048557to the value of aforementioned pagedata?