from robobrowser import RoboBrowser
crawler = RoboBrowser(history=True)
crawler.open('http://www.whatever.com/')
search_form = crawler.get_form(attrs={'name':'formName') #This is the name found in <formname=formName>
search_form['keywords'] = 'search keywords' # In form[] specify the <input name=''> of the subfield within the form element that you're trying to fill in.
crawler.submit_form(search_form)`
如果还没有,可以考虑查看twill。Twill基于mechanize包,有一个submit function,可以用来点击按钮。在
试试RoboBrowser,它是建立在机械化和美丽的汤之上。在
示例代码:
您可能还想看看ghost.py,它提供了一个可通过Python访问的无头WebKit浏览器(基本上是PhantomJS的Python变体)。或者点击任意按钮都没有问题(在填写表单之后,甚至评估一些JS)。在
相关问题 更多 >
编程相关推荐