Python 万维网宏 [英] Python WWW macro

查看:70
本文介绍了Python 万维网宏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要类似 iMacros for Python 的东西.有这样的东西会很棒:

i need something like iMacros for Python. It would be great to have something like that:

browse_to('www.google.com')
type_in_input('search', 'query')
click_button('search')
list = get_all('<p>')

你知道这样的事情吗?

提前致谢,埃塔姆.

推荐答案

几乎直接实现了问题中的愿望 - 斜纹.

Almost a direct fulfillment of the wishes in the question - twill.

twill 是一种简单的语言,允许用户从命令行界面浏览 Web.使用 twill,您可以浏览使用表​​单、cookie 和大多数标准网络功能的网站.

twill is a simple language that allows users to browse the Web from a command-line interface. With twill, you can navigate through Web sites that use forms, cookies, and most standard Web features.

twill 支持自动化 Web 测试并具有简单的 Python 界面.

twill supports automated Web testing and has a simple Python interface.

(为方便起见,pyparsingmechanizeBeautifulSoup 包含在 twill 中.)

(pyparsing, mechanize, and BeautifulSoup are included with twill for convenience.)

一个 Python API 示例:

from twill.commands import go, showforms, formclear, fv, submit

go('http://issola.caltech.edu/~t/qwsgi/qwsgi-demo.cgi/')
go('./widgets')
showforms()

formclear('1')
fv("1", "name", "test")
fv("1", "password", "testpass")
fv("1", "confirm", "yes")
showforms()

submit('0')

这篇关于Python 万维网宏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆