I was trying to submit the search salary form (middle one) in this page: http://www.glassdoor.com/Salaries/index.htm using Python 2.7 mechanize 0.2.5.
However, I can't find a way to set value in the second input box since it has no name or id, only class. I can target this form as well as the first input box. Is there any way to set value to the next input box?
Here is my code:
url = "http://www.glassdoor.com/Salaries/index.htm"
br = mechanize.Browser()
br.set_handle_robots(False) # ignore robots
br.addheaders = [('User-agent', 'Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.1) Gecko/2008071615 Fedora/3.0.1-1.fc9 Firefox/3.0.1')]
br.open(url)
br.select_form(nr=1)
br["sc.keyword"] = "Data Analyst"
br[None] = "San Francisco" # this line is problematic
res = br.submit()
print res.geturl()
The form printed out like this:
<GET http://www.glassdoor.com/Salaries/company-salaries.htm application/x-www-form-urlencoded
<HiddenControl(suggestCount=0) (readonly)>
<HiddenControl(suggestChosen=false) (readonly)>
<HiddenControl(clickSource=searchBtn) (readonly)>
<HiddenControl(typedKeyword=) (readonly)>
<TextControl(sc.keyword=)>
<TextControl(<None>=)>
<HiddenControl(locT=) (readonly)>
<HiddenControl(locId=) (readonly)>
<HiddenControl(jobType=all) (readonly)>
<SubmitButtonControl(<None>=) (readonly)>
<SubmitButtonControl(<None>=) (readonly)>>
How can I set value to the second 'TexControl'? Thanks!