编辑:秩名2023-07-02 13:00:01
本文实例讲述了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网站,同时输出如下结果:
DownloadBegin test DownloadComplete DownloadBegin test DownloadComplete documentComplete of http://pos.baidu.com/acomadn=0ltr=&cf=u 2 DownloadBegin test DownloadComplete
希望本文所述对大家的Python程序设计有所帮助。
python实现的重启关机程序实例
python实现自动登录人人网并采集信息的方法
python自动zip压缩目录的方法
python实现自动更换ip的方法
Python自动重试HTTP连接装饰器
python定时检查某个进程是否已经关闭的方法
python关闭windows进程的方法
python实现自动重启本程序的方法