Reputation: 1864
I'm very new to python and I'm trying to 'select' a radio button that is within a survey on a website. I really have no idea where to start with the python code. I believe the survey is in javascript and when the submit button is clicked, it sends the data to the server running the survey. The code I got from the survey radiobutton is as follows
<input type="radio" class="sg-input sg-input-radio" name="sgE-1416699-3-2" id="sgE-1416699-3-2-10002" value="10002" title="Name of RadioButton">
The code I have of the submit button is here
<input type="submit" class="sg-button sg-submit-button" id="sg_SubmitButton" name="sGizmoSubmitButton" data-domain="www.surveygizmo.com" value="Vote">
Any help on how this is to be done will be greatly appreciated. Thanks.
Upvotes: 1
Views: 4912
Reputation: 18028
Suppose you have these params:
sgE-1416699-3-2 = 10002
more_param = param_value
Then prepare:
from urllib import urlopen, urlencode
data = {'sgE-1416699-3-2':'10002', 'more_param':'param_value'}
encodeddata = urlencode(data)
url = 'http://surveygizmo.com'
Now, to make a GET request:
r = urlopen("{0}?{1}".format(url, encodeddata))
To make a POST request:
r = urlopen(url, encodeddata)
Read the response:
r.read()
Upvotes: 1