我正在使用mechanize抓取一些页面。分页是由javascript post实现的,分页链接实际上是input按钮。这些内容不包含在表单中。你知道我怎么才能点击这些吗?
我仍在编写脚本,可以使用mechanize-ruby或mechanize-python。任何一种解决方案都会有所帮助。
按钮的html为:
<input name="px" value="1" class="pSel" disabled="true\" type="button">
<input name="px" value="2" class="page_select" onclick="apply_pagination(this);" type="button">
<input name="px" value="3" class="page_select" onclick="apply_pagination(this);" type="button">
...
<input name="px" value="10" class="page_select" onclick="apply_pagination(this);" type="button">发布于 2012-07-18 00:17:39
使用mechanize ruby,您可以通过以下方式找到POST参数:
apply_pagination javascript方法,找出它回发到web服务器的内容。有了它,你就可以很容易地复制web服务器期望从用户代理得到的东西,并做一些与此相近的事情;
next_page = agent.post("http://example.com/", { "foo" => "bar" })https://stackoverflow.com/questions/11228003
复制相似问题