文章详情页
Python自动调用IE打开某个网站的方法
浏览:25日期:2022-08-07 18:46:02
本文实例讲述了Python自动调用IE打开某个网站的方法。分享给大家供大家参考。具体实现方法如下:
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网站,同时输出如下结果:
DownloadBegintestDownloadCompleteDownloadBegintestDownloadCompletedocumentComplete of http://pos.baidu.com/acomadn=0ltr=&cf=u2DownloadBegintestDownloadComplete希望本文所述对大家的Python程序设计有所帮助。
您可能感兴趣的文章:python实现的重启关机程序实例
python实现自动登录人人网并采集信息的方法
python自动zip压缩目录的方法
python实现自动更换ip的方法
Python自动重试HTTP连接装饰器
python定时检查某个进程是否已经关闭的方法
python关闭windows进程的方法
python实现自动重启本程序的方法
相关文章:
1. 解决Docker network Create加--subnet后遇到问题2. golang json数组拼接的实例3. JavaScript中break、continue和return的用法区别实例分析4. 编写更好的 Java 单元测试的 7 个技巧5. 详解Intellij IDEA的Facets和Artifacts6. PHP中的闭包function() use() {}使用场景和技巧7. 解决SpringBoot返回结果如果为null或空值不显示处理问题8. IntelliJ IDEA导出项目的方法9. 详解PHP laravel中的加密与解密函数10. js实现自定义右键菜单
排行榜

网公网安备