Python自動調(diào)用IE打開某個網(wǎng)站的方法
本文實(shí)例講述了Python自動調(diào)用IE打開某個網(wǎng)站的方法。分享給大家供大家參考。具體實(shí)現(xiàn)方法如下:
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.dhdzp.com")
pythoncom.PumpMessages()
ie.Quit()
運(yùn)行該程序可打開www.dhdzp.com網(wǎng)站,同時輸出如下結(jié)果:
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.dhdzp.com%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=&scale=&skin=tabcloud_skin_6&stid=5&td_id=1919103&tn=baiduCustSTagLinkUnit&tpr=1433304842125&ts=1&version=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.dhdzp.com&tt=1433304842078.47.125.125 2 documentComplete of http://www.dhdzp.com/ 2 DownloadBegin test DownloadComplete documentComplete of http://pos.baidu.com/wh/o.htm?ltr=&cf=u 2 DownloadBegin test DownloadComplete
希望本文所述對大家的Python程序設(shè)計有所幫助。
相關(guān)文章
python實(shí)現(xiàn)將文件夾下面的不是以py文件結(jié)尾的文件都過濾掉的方法
今天小編就為大家分享一篇python實(shí)現(xiàn)將文件夾下面的不是以py文件結(jié)尾的文件都過濾掉的方法,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧2018-10-10
pytorch lstm gru rnn 得到每個state輸出的操作
這篇文章主要介紹了pytorch lstm gru rnn 得到每個state輸出的操作,具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教2021-05-05
python實(shí)現(xiàn)微信接口(itchat)詳細(xì)介紹
這篇文章主要介紹了python實(shí)現(xiàn)微信接口(itchat)詳細(xì)介紹,小編覺得挺不錯的,這里分享給大家,供需要的朋友參考。2017-10-10
一個簡單的python爬蟲程序 爬取豆瓣熱度Top100以內(nèi)的電影信息
這篇文章主要為大家詳細(xì)介紹了一個簡單的python爬蟲程序,爬取豆瓣熱度Top100以內(nèi)的電影信息,具有一定的參考價值,感興趣的小伙伴們可以參考一下2018-04-04
Python 執(zhí)行字符串表達(dá)式函數(shù)(eval exec execfile)
今天在網(wǎng)上搜尋一些應(yīng)用的例子時,發(fā)現(xiàn)有人用TK僅僅幾行代碼就寫了個簡易的計算器,驚為天人。回憶起剛學(xué)軟件技術(shù)基礎(chǔ)時編寫簡易計算器的艱辛,頓時淚流滿面2014-08-08
Python使用Rich實(shí)現(xiàn)美化終端顯示效果
Rich庫的功能就像它的名字一樣,使Python編程更加豐富(rich),用來幫助開發(fā)者在控制臺(命令行)輸出中創(chuàng)建豐富、多彩和具有格式化的文本,下面我們就來了解下它的具體使用吧2024-02-02

