欢迎来到山村网

Python自动调用IE打开某个网站的方法

2019-03-02 13:53:09浏览:517 来源:山村网   
核心摘要:  本文实例讲述了Python自动调用IE打开某个网站的方法。分享给大家供大家参考。具体实现方法如下:  ? 12345678910111213141

  本文实例讲述了Python自动调用IE打开某个网站的方法。分享给大家供大家参考。具体实现方法如下:

  ?

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 import win32gui import win32com import win32com.client import pythoncom import time class Test: def runtest(self): print 'test' class EventHandler: def onVisible(self,visible): global bVisibleEventFired bVisibleEventFired = 1 def onDownloadBegin(self): print 'DownloadBegin' self.runtest() self.value = 1 def onDownloadComplete(self): print 'DownloadComplete' self.value += 1 def ondocumentComplete(self,pDisp=pythoncom.Missing,URL=pythoncom.Missing): print 'documentComplete of %s' %URL print self.value class H(Test,EventHandler): pass ie = win32com.client.DispatchWithEvents('InternetExplorer.Application',H) ie.Visible = 1 ie.Navigate("www.jb51.net") pythoncom.PumpMessages() ie.Quit()

  运行该程序可打开www.jb51.net网站,同时输出如下结果:

  ?

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 DownloadBegin test DownloadComplete DownloadBegin test DownloadComplete documentComplete of http://pos.baidu.com/acom?adn=0&at=128&aurl=&cad=1&ccd=32&cec=gb2312&cfv=17&ch =0&col=zh-cn&conOP=0&cpa=1&dai=1&dis=0&layout_filter=rank%2Cimage<r=<u=http%3A%2F%2Fwww.jb51.net% 2F&lunum=6&n=jb51_cpr&pcs=1387x729&pis=10000x10000&ps=2348x191&psr=1440x900&pss=1387x2350&qn= 6a0cce8cf992d19c&rad=&rsi0=1000&rsi1=60&rsi5=4&rss0=&rss1=&rss2=&rss3=&rss4=&rss5=&rss6=&rss7=&s cale=&skin=tabcloud_skin_6&stid=5&td_id=1919103&tn=baiduCustSTaglinkUnit&tpr=1433304842125&ts=1&ve rsion=2.0&xuanting=0&dtm=BAIDU_DUP2_SETJSONADSLOT&dc=2&di=u1919103&ti=%E8%84%9A%E6%9C% AC%E4%B9%8B%E5%AE%B6_www.jb51.net&tt=1433304842078.47.125.125 2 documentComplete of http://www.jb51.net/ 2 DownloadBegin test DownloadComplete documentComplete of http://pos.baidu.com/wh/o.htm?ltr=&cf=u 2 DownloadBegin test DownloadComplete

  希望本文所述对大家的Python程序设计有所帮助。

(责任编辑:豆豆)
下一篇:

jQuery中extend()和fn.extend()方法详解

上一篇:

python实现支持目录FTP上传下载文件的方法

  • 信息二维码

    手机看新闻

  • 分享到
打赏
免责声明
• 
本文仅代表作者个人观点,本站未对其内容进行核实,请读者仅做参考,如若文中涉及有违公德、触犯法律的内容,一经发现,立即删除,作者需自行承担相应责任。涉及到版权或其他问题,请及时联系我们 xfptx@outlook.com