Background:
Using urllib and urllib2 in Python, you can do a form submission.
You first create a dictionary.
formdictionary = { 'search' : 'stackoverflow' }
Then you use urlencode method of urllib to transform this dictionary.
params = urllib.urlencode(formdictionary)
You can now make a url request with urllib2 and pass the variable params as a secondary parameter with the first parameter being the url.
open = urllib2.urlopen('www.searchpage.com', params)
From my understanding, urlencode automatically encodes the dictionary in html and adds the input tag. It takes the key to be the name attribute. It takes value in the dictionary to be the value of the name attribute. Urllib2 send this html code via an HTTP POST request.
Problem:
This is alright if the html code you are submitting to is formatted in a standard way with the html tag input having the name attribute.
<input id="32324" type="text" name="search" >
But, there is the situation where the html code is not properly formatted. And the html input tag only has an id attribute no name attribute. Is there may be another way to access the input tag via the id attribute? Or is there may be yet another way?
Solution:
?