Web scraping 单击输入标记,而不是表单中的
我在用Web scraping 单击输入标记,而不是表单中的,web-scraping,mechanize,mechanize-ruby,mechanize-python,Web Scraping,Mechanize,Mechanize Ruby,Mechanize Python,我在用机械化刮几页。分页由javascript post实现,分页链接实际上是input按钮。这些不包括在表格中。你知道我怎么能点击这些吗 我还在编写脚本,可以使用mechanizeruby或mechanizepython。任何一种解决方案都会有所帮助 按钮的html为: <input name="px" value="1" class="pSel" disabled="true\" type="button"> <input name="px" value="2" class
机械化刮几页。分页由javascript post实现,分页链接实际上是input
按钮。这些不包括在表格中。你知道我怎么能点击这些吗
我还在编写脚本,可以使用mechanizeruby
或mechanizepython
。任何一种解决方案都会有所帮助
按钮的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">
...
使用mechanize ruby,您可以通过以下方式找到POST参数:
查看apply_pagination
javascript方法,找出它向web服务器发回的内容
单击浏览器上的一个链接,并使用类似[HTTPFox]的内容监视POST请求(https://addons.mozilla.org/en-us/firefox/addon/httpfox/)
有了它,您就可以轻松地复制web服务器对用户代理的期望,并完成类似的工作
next_page = agent.post("http://example.com/", { "foo" => "bar" })