I want to trigger radio button with python-requests.
Currently I am looking what is happening when radio button is manually selected:
XHR to: http://exmp-url/admin-ajax.php
HEADERS:
'Accept': '*/*',
'Accept-Encoding': 'gzip, deflate',
'Accept-Language': 'pl-PL,pl;q=0.9,en-US;q=0.8,en;q=0.7,de;q=0.6',
'Connection': 'keep-alive',
'Content-Length': '110',
'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
'X-Requested-With': 'XMLHttpRequest'
Payload:
'operacja': 'ShowRezerwacjeTable',
'action': 'ShowRezerwacjeTable',
'data': '2019-03-19',
'obiekt_typ': 'badminton',
'godz_od': '',
'godz_do': ''
I am trying to mimic and send data with the same payload and headers:
with Session() as c:
c.post(login_page, data=payload)
# Getting page content after logging in.
response = c.get(reservation_page)
content = response.content
c.headers.update(headers)
resp = c.post('http://http://exmp-url/admin-ajax.php', data=payload2)
# Getting new content that should have altered HTML after radio button is checked.
new_content = codecs.decode(resp.content, encoding="utf-8-sig")
The response's status code is 200 while content is b'\xef\xbb\xbf' and after decoding it's empty.
What am I doing wrong? Maybe I should switch approach and instead try to click on the button itself. I would prefer not to use selenium. Is robobrowser perferred here without the visible form element?
Checked radio button's HTML:
<input type="radio" id="rez_obiekt_typ_t" name="obiekt_typ" data-obiekt_typ="tenis" checked="" value="tenis" class="ui-helper-hidden-accessible">