文章詳情頁
Python自動調用IE打開某個網站的方法
瀏覽:2日期: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實現自動重啟本程序的方法
相關文章:
排行榜
