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

