pythoncqt_在python中打开网站框架或图像

So i am fairly fluent with python and have used urllib2 and Cookies a lot for website automation. I just stumbled upon the "webbrowser" module which can open a url in your default browser. Im wondering if its possible to select just one object from that url and open that up. Specifically i want to open a "captcha" so that the user can input it, and continue doing something else.

this is line containing the captcha in the html, i think:

script type="text/javascript" src="http://api.recaptcha.net/challenge?k=6LcZ-AAAAAAAANX-xwVtzow1f4RpSrbSViRUx9Js">

and clicking on that api link opens this:

var RecaptchaState = {

site : '6LcZ-AAAAAAAANX-xwVtzow1f4RpSrbSViRUx9Js',

challenge : '03AHJ_VuvoUHPdfoXLsVHGa7a26GR9s9Y5dkyKmqk2XsJ1SdiwF_2u0SV_sKnr1artkpc-5MjUe7SYD40xr7sAyvikKwpFCQTBdKUFfl76UP6EbDhezoTC8B1X8fjixuIJ4wJhI6yTc8vlX4ioh6je9lwFbPXllbGh2w',

is_incorrect : false,

programming_error : '',

error_message : '',

server : 'http://www.google.com/recaptcha/api/',

timeout : 18000

};

document.write('');

any info would help with this.

解决方案

It's not possible with the webbrowser module. All webbrowser does is provide a simple way to identify the default web browser and feed a URL to it.

If you want to render just a portion of a page, you need something that can either take arbitrary HTML fragments or can inject some Javascript after loading a page to strip out the unwanted elements.

For that, what you need is to build a purpose-specific web browser that's nothing more than a dialog box containing a web widget.

That can be done using any of the following combinations of libraries:

PyQt and the included QtWebKit (GPL or Commercial, Windows/Mac/Linux)

PySide and the included QtWebKit (LGPL, Linux)

PyGTK and PyWebKitGTK (LGPL, Easy on Linux... no clue about Windows or OSX)

PyGTK and GTKMozEmbed (LGPL, Easy on Linux... no clue about Windows or OSX)

wxPython and the included wxIEHtmlWindow (BSD-like, Windows-only. Embeds Internet Explorer.)

wxPython and the included wxWebKitCtrl (BSD-like, OSX-only)

wxPython and wxWebKit (BSD-like, Windows/Mac/Linux)

My advice:

If GPL licensing is OK, use PyQt.

If GPL licensing isn't OK:

For Linux, use PySide or PyGTK with PyWebKitGTK (GTKMozEmbed is heavy)

For Windows, use wxPython with wxIEHtmlWindow

For OSX, you'll have to ask someone else.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值