我试图使用python请求模块发出Post请求,但我最感兴趣的输入只有id和no name属性。我看到的所有例子都涉及到使用name属性。我怎样才能申请以下表格:
<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>
我特别关注的是带有^{id1}的输入$
目前,我正在尝试这个代码:(这只是给我的原始主页与搜索栏)
data = {
'searchInput': name,
'searchVal' : "horses"
}
r = requests.post(self.equibaseHomeUrl, data=data)
如果您查看firebug或chrome开发工具,可以看到post请求是如何发出的:
因此我们可以:
如果你查看内容,你可以看到Zenyatta的搜索结果。
或者,如果要使用基本url并传递查询:
如果您运行它,您将看到url被正确构造:
相关问题 更多 >
编程相关推荐