I'm trying to make a Post request using the python request module, but the input I am most interested in only has an id and no name attribute. And all the examples I've seen involve using that name attribute. How can I do this Post request for the following form:
<form id="search" method="post">
<select id="searchOptions" onchange="javascript:keepSearch(this);">
<option value="horses" selected>Horses</option>
<option value="jockeys">Jockeys</option>
<option value="trainers">Trainers</option>
<option value="owners">Owners</option>
<option value="tracks">Tracks</option>
<option value="stakes">Gr. Stakes</option>
</select>
<input type="hidden" id="searchVal" value="horses" name="searchVal">
<input class="input" id="searchInput" type="text" placeholder="Horse Name">
<span class="glyphicon glyphicon-search"></span>
<input type="submit" value="">
<span style="clear: both;">.</span>
</form>
I'm looking specifically at the input with the id="searchInput".
Currently, I'm trying this code: (which is only getting me the original homepage with the search bar)
data = {
'searchInput': name,
'searchVal' : "horses"
}
r = requests.post(self.equibaseHomeUrl, data=data)
If you take a look in firebug or chrome developer tools you can see how the post request is made:
So using that we can:
Which if you look at the content you can see the search result for Zenyatta.
Or if you want to use the base url and pass the query:
Which if you run it you will see url get constructed correctly: