It is simple enough to send a GET
request to the url https://apps.fpb.org.za/erms/fpbquerytitle.aspx?filmtitle=&Submit1=Search
to get the 1st page of search results of the wesbite.
However, I cannot figure out how to request subsequent pages, which involve sending a POST
request to the same url but with a lot form data parameters.
I have managed to get the results of page 2 as follows
with requests.session() as s:
### REQUESTING FIRST PAGE
r = s.request('get', 'https://apps.fpb.org.za/erms/fpbquerytitle.aspx?filmtitle=&Submit1=Search')
soup = BeautifulSoup(r.content, 'html.parser')
### REQUESTING SECOND PAGE
page_number = 2
form_data = {
'__EVENTTARGET': '',
'__EVENTARGUMENT': '',
'__VIEWSTATE': soup.find('input', id = '__VIEWSTATE').get('value'),
'__VIEWSTATEGENERATOR': soup.find('input', id = '__VIEWSTATEGENERATOR').get('value'),
'__EVENTVALIDATION': soup.find('input', id = '__EVENTVALIDATION').get('value'),
'vwfpbquerytitle_DXKVInput': soup.find('input', id = 'vwfpbquerytitle_DXKVInput').get('value'),
'vwfpbquerytitle$CallbackState': soup.find('input', id = 'vwfpbquerytitle_CallbackState').get('value'),
'vwfpbquerytitle$DXSelInput': soup.find('input', id = 'vwfpbquerytitle_DXSelInput').get('value'),
'vwfpbquerytitle_DXHFPWS': soup.find('input', id = 'vwfpbquerytitle_DXHFPWS').get('value'),
'popupControlWS': soup.find('input', id = 'popupControlWS').get('value'),
'DXScript': '1_155,1_87,1_147,1_97,1_123,1_106,1_113,1_84,1_139,1_137,1_98,1_135',
'__CALLBACKID': 'vwfpbquerytitle',
'__CALLBACKPARAM': (
f"c0:KV|777;{soup.find('input', id = 'vwfpbquerytitle_DXKVInput').get('value')};GB|20;12|PAGERONCLICK3|PN{page_number - 1};",
),
}
r2 = s.request('post', 'https://apps.fpb.org.za/erms/fpbquerytitle.aspx?filmtitle=&Submit1=Search', data = form_data)
soup2 = BeautifulSoup(r.content, 'html.parser')
But the last response r2
does not give me any indication for what the constantly changing __CALLBACKPARAM
and vwfpbquerytitle$CallbackState
parameters should be for the next request, as they are not present anywhere in the HTML response. In fact the only reason I can set the __CALLBACKPARAM
correctly for the 2nd request above is because I can see by inspecting the website that the patterns such as c0:KV|777
, etc. are always there for that 2nd request.
So my question is how can I request subsequent pages past this point? Because setting __CALLBACKPARAM
in the previous way, e.g.
page_number = 5
'__CALLBACKPARAM': f"c0:KV|777;{soup.find('input', id = 'vwfpbquerytitle_DXKVInput').get('value')};GB|20;12|PAGERONCLICK3|PN{page_number - 1};"
just gives me the same 2nd page of results as before