网络自动化(是:按网页按钮) [英] Web automation (was: Pressing a Webpage Button)

查看:62
本文介绍了网络自动化(是:按网页按钮)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

6月1日的Elliot Temple写道:

Hi all,
Elliot Temple on the 1 June wrote:

如何让Python按下网页上的按钮?我看了一下
urllib,但我只看到如何用它打开一个URL。我搜索谷歌但没有运气。
例如,谷歌有一个按钮< input type = submit value =" Google
Search"命名= btnG>我如何制作一个脚本按下那个按钮?


我有一个类似的目标:网络自动化,

不仅需要按下网页按钮而且还需要

填写输入字段(例如在你的情况下,谷歌的

搜索字段)。

关于gmi ... @ gmail.com的建议,我试过了

twill( http://www.idyll。 org /~t / www-tools / twill.html)


我认为它可以解决方案:

我已经应用了它用于从asp文件中读取数据

http://groups.google.it/group/comp.l...0a593e08d28baf

我尝试使用交互模式解决您的问题

(但也可以将twill称为模块)。


在交互模式下设置斜纹:twill- sh $ / $
- 加载Google webpa ge:

www.google.it (我是' m意大利语!)

- 显示带有''show'命令的页面'

- 获取页面表格:

showforms


## __Name______ __Type___ __ID________ __Value__________________

hl隐藏(无)它

即隐藏(无)ISO-8859-1

q文本(无)

元收音机所有['''']的'''',''lr = lang_it'',

' 'cr = count ...

1 btnG提交(无)Cerca con Google

2 btnI提交(无)Mi sento fortunato

当前页面: http://www.google.it


输入字段是q(类型:文本),而有两个按钮

(类型:提交)和单选按钮元(类型:无线电)。

- 填充值:

fv 0 q twill

(是twill;搜索字符串)

- 按搜索按钮:

fv 1 btnG" Cerca con Google"

submit

twill对Google的查询回答:
http://www.google.it/search?hl=it&ie...n+Google&meta=

- 将搜索结果保存在文件中:

save_html /home/qwweeeit/searching_twill.html


这里他们是第10次点击搜索!

不要让我继续!也许向斜纹作者询问

(C。Titus Brown)......


使用这种方法你可以绕过谷歌的限制,因为

你正在使用浏览器(只能自动构建查询)。


这回答了对格兰德爱德华兹的正确观察:啊,没关系。那不行。谷歌以某种方式检测到你没有从浏览器发送查询并让你感到麻烦。
How do I make Python press a button on a webpage? I looked at
urllib, but I only see how to open a URL with that. I searched
google but no luck. For example, google has a button <input type=submit value="Google
Search" name=btnG> how would i make a script to press that button?
I have a similar target: web automation, which
needs not only to press web buttons but also
fill up input fields (like in your case the
search field of Google).
On the suggestion of gmi...@gmail.com, I tried
twill (http://www.idyll.org/~t/www-tools/twill.html).

I think it can be the solution:
I already applied it for reading data from an asp file
(http://groups.google.it/group/comp.l...0a593e08d28baf)
I try to solve your problem using the interactive mode
(but twill can also be called as a module).

Set twill in interactive mode: twill-sh
- load Google webpage:
go www.google.it (I''m Italian!)
- show the page with the command ''show''
- Get the page forms:
showforms

## __Name______ __Type___ __ID________ __Value__________________
hl hidden (None) it
ie hidden (None) ISO-8859-1
q text (None)
meta radio all [''''] of ['''', ''lr=lang_it'',
''cr=count ...
1 btnG submit (None) Cerca con Google
2 btnI submit (None) Mi sento fortunato
current page: http://www.google.it

The input field is q (Type:text), while there are two buttons
(Type: submit) and a radio button meta (Type: radio).

- fill values:
fv 0 q twill
(being "twill" the search string")
- press the search button:
fv 1 btnG "Cerca con Google"
submit
twill answers with the query to Google:
http://www.google.it/search?hl=it&ie...n+Google&meta=
- save the search result on a file:
save_html /home/qwweeeit/searching_twill.html

Here they are the 1st 10 hits of the search!
Don''t ask me to continue! Perhaps asking to the author of twill
(C. Titus Brown)...

With such a method you can bypass the Google''s restrictions, because
you are using the browser (only building automatically the query).

And this answers to the right observation of Grant Edwards: Ah, never mind. That doesn''t work. Google somehow detects
you''re not sending the query from a browser and bonks you.




再见。



Bye.

推荐答案

你好,


这很容易看到下面的代码:

# ################################################## #######################
来自win32com.client导入的
DispatchEx

导入时间

#instaniate一个新的IE对象

ie = DispatchEx(''InternetExplorer.Application'')


#Naviagte to网站

ie.Navigate(" www.google.com")

#您必须等待网站加载。最好使用一种方法来检查

for readystate =" complete" ie.Busy

而ie.Busy:

time.sleep(0.1)


doc = self._ie.Document


而doc.readyState!=''完成'':

time.sleep(0.1)


ie.Document.all [" q"]。value =" Python rocks"

ie.Document.all [" btnG"]。click()


我有一个包装器可以为你做这一切。它适用于

QA的人。你可以在这里下载

网址: http://pamie.sourceforge.net

使用它很简单等待文件的等待已经在代码中

############################### ############

来自cPAMIE导入PAMIE


ie = PAMIE()


ie.Navigate( www.google.com

>
#设置text - arguments - value to set,textbox name,formname

ie.SetTextBox(''Python"," q"," f")

ie.ClickButton(" btnG," f")

ie.ClickLink(''Python Programming Language'')


希望这有帮助


Rob

qw ***** *@yahoo.it 写道:
大家好,
Elliot Temple在6月1日写道:
Hi all,
Elliot Temple on the 1 June wrote:
如何让Python按下按钮在网页上?我看了一下
urllib,但我只看到如何用它打开一个URL。我搜索了谷歌但没有运气。
How do I make Python press a button on a webpage? I looked at
urllib, but I only see how to open a URL with that. I searched
google but no luck.


例如,谷歌有一个按钮< input type = submit value =" Google
Search" ;命名= btnG>我如何制作一个脚本来按下那个按钮?
For example, google has a button <input type=submit value="Google
Search" name=btnG> how would i make a script to press that button?



我有一个类似的目标:网络自动化,它不仅需要按下网页按钮而且还需要
填写输入字段(比如你的情况是谷歌的搜索字段)。
关于gmi ... @ gmail.com的建议,我试过了
twill( http://www.idyll.org/~t/www-tools/ twill.html)

我认为它可以是解决方案:
我已经应用它来读取asp文件中的数据
http:/ /groups.google.it/group/comp.l...0a593e08d28baf
我尝试使用交互模式解决您的问题
(但斜纹也可以称为模块) 。

在交互模式下设置斜纹:twill-sh
- 加载Google网页:
www.google.it (我是意大利人!)
- 使用命令''show'显示页面'
- 获取页面表格:
showforms

hl hidden(无)它
即隐藏(无)ISO-8859-1
q text(无)
meta radio所有['''']的'''',''lr = lang_it' ',
''cr = count ...
1 btnG提交(无)Cerca con Google
2 btnI提交(无)Mi sento fortunato
当前页面: http://www.google.it

输入字段为q(键入:文本),同时有两个按钮
(类型:提交)和一个单选按钮元(类型:收音机)。

- 填充值:
fv 0 q twill
(正在&qu OT;斜纹"搜索字符串)
- 按搜索按钮:
fv 1 btnGCerca con Google
提交
斜纹答案并向Google查询:
< a rel =nofollowhref =http://www.google.it/search?hl=it&ie=ISO-8859-1&q=twill&btnG=Cerca+con+Google&meta=target = _blank> http://www.google.it/search?hl=it&ie...n+Google&meta=
- 将搜索结果保存在文件中:
save_html /home/qwweeeit/searching_twill.html

在这里,他们是搜索的第10次点击!
不要让我继续!也许向斜纹作者询问(C. Titus Brown)......

使用这种方法你可以绕过谷歌的限制,因为你正在使用
浏览器(仅自动构建查询)。

这回答了对Grant Edwards的正确观察:



I have a similar target: web automation, which
needs not only to press web buttons but also
fill up input fields (like in your case the
search field of Google).
On the suggestion of gmi...@gmail.com, I tried
twill (http://www.idyll.org/~t/www-tools/twill.html).

I think it can be the solution:
I already applied it for reading data from an asp file
(http://groups.google.it/group/comp.l...0a593e08d28baf)
I try to solve your problem using the interactive mode
(but twill can also be called as a module).

Set twill in interactive mode: twill-sh
- load Google webpage:
go www.google.it (I''m Italian!)
- show the page with the command ''show''
- Get the page forms:
showforms

## __Name______ __Type___ __ID________ __Value__________________
hl hidden (None) it
ie hidden (None) ISO-8859-1
q text (None)
meta radio all [''''] of ['''', ''lr=lang_it'',
''cr=count ...
1 btnG submit (None) Cerca con Google
2 btnI submit (None) Mi sento fortunato
current page: http://www.google.it

The input field is q (Type:text), while there are two buttons
(Type: submit) and a radio button meta (Type: radio).

- fill values:
fv 0 q twill
(being "twill" the search string")
- press the search button:
fv 1 btnG "Cerca con Google"
submit
twill answers with the query to Google:
http://www.google.it/search?hl=it&ie...n+Google&meta=
- save the search result on a file:
save_html /home/qwweeeit/searching_twill.html

Here they are the 1st 10 hits of the search!
Don''t ask me to continue! Perhaps asking to the author of twill
(C. Titus Brown)...

With such a method you can bypass the Google''s restrictions, because
you are using the browser (only building automatically the query).

And this answers to the right observation of Grant Edwards:

啊,没关系。那不行。谷歌以某种方式检测到你没有从浏览器发送查询并让你感到麻烦。
Ah, never mind. That doesn''t work. Google somehow detects
you''re not sending the query from a browser and bonks you.



再见。



Bye.






如果您正在寻找使用Python的解决方案,Twill或Pamie看起来不错。


如果您正在寻找跨浏览器测试解决方案,那么

也是这样做的selenium。

有一些用于Python的代码。


RUBY和SAMIE中也有WATIR在PERL


这取决于你的环境和需求。


希望有所帮助!!

Rob M.

Twill or Pamie looks good, if your looking for a solution using Python.

If you are looking for Cross- browser solution for testing there is
also selenium that does that.
The have some code for use in Python.

There is also WATIR in RUBY and SAMIE in PERL

It depends on your enviroment and needs.

Hope that helps!!
Rob M.


如果您正在寻找使用Python的解决方案,Twill或Pamie看起来不错。


如果您正在寻找对于用于测试的跨浏览器解决方案,

也可以使用selenium。

有一些代码可以在Python中使用。


在RUBY还有WATIR和PERL中的SAMIE


这取决于你的环境啰嗦和需求。


希望有所帮助!!

Rob M.

Twill or Pamie looks good, if your looking for a solution using Python.

If you are looking for Cross- browser solution for testing there is
also selenium that does that.
The have some code for use in Python.

There is also WATIR in RUBY and SAMIE in PERL

It depends on your enviroment and needs.

Hope that helps!!
Rob M.


这篇关于网络自动化(是:按网页按钮)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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