使用python页面上的按钮

时间:2013-03-15 01:38:36

标签: python web-scraping

我正在为某些数据抓取页面,但是我需要在文本框中插入文本,提交表单并抓取结果页面。我查看了页面源代码,但我不确定如何激活按钮或传递参数。

网站为http://archive.org/web/web.php 试着看一些历史,不知道该用什么。开放给任何解决方案

1 个答案:

答案 0 :(得分:1)

首先,您应该知道点击该按钮通常会对某些网址执行 POST ,传递该表单中的数据,此处为:

<form id="wwmform" name="wwmform" method="get" action="http://web.archive.org/form-submit.jsp" onsubmit="document.location.href='http://web.archive.org/web/*/'+document.getElementById('wwmurl').value;return false;" style="display:inline;">
      <input id="wwmurl" type="text" name="url" size="50" value="http://">
      <button type="submit" name="type" value="urlquery" class="roundbox5">Take Me Back</button>
    </form>

您是否看到操作属性?这就是数据的来源。

因此在python中,您可能需要urlliburllib2对数据进行编码并将其发布到目标网址,然后获取结果。

ps:注意onsubmit