python使用win32com在百度空間插入html元素示例
from win32com.client import DispatchEx
import time
ie=DispatchEx("InternetExplorer.Application")
ie.Navigate("http://hi.baidu.com/mirguest/creat/blog/")
ie.Visible=1
while ie.Busy:
time.sleep(1)
body=ie.Document.body
# header
for i in body.getElementsByTagName("input"):
if str(i.getAttribute("id"))=="spBlogTitle":
print "Find title"
i.value="AutoCreatedByPython"
break
# editor
for i in body.getElementsByTagName("iframe"):
print "Find iframe"
if str(i.getAttribute("id"))=="tangram_editor_iframe_TANGRAM__1":
print "Find"
break
iframe=i
iframe.click()
sondoc=iframe.contentWindow.Document;
print sondoc
sonbody=sondoc.body
print sonbody
for ii in sonbody.getElementsByTagName("p"):
print "Find p"
ii.innerHTML="hello,my first try"
tmp=sondoc.createElement("div")
tmp.innerHTML="bye"
sonbody.insertBefore(tmp,ii)
tmpHTML="<div>hello 2</div>"
sonbody.insertAdjacentHTML("beforeEnd",tmpHTML)
'''
editor.getContentHTML
'''
# submit
for i in body.getElementsByTagName("div"):
if str(i.getAttribute("id"))=="btn-box":
print "Find button"
break
btnbox=i
j=btnbox.childNodes(0)
j.click()
- python字符串加密解密的三種方法分享(base64 win32com)
- Python win32com 操作Exce的l簡(jiǎn)單方法(必看)
- python使用win32com庫(kù)播放mp3文件的方法
- Python使用win32com實(shí)現(xiàn)的模擬瀏覽器功能示例
- 使用Python通過win32 COM實(shí)現(xiàn)Word文檔的寫入與保存方法
- 使用Python通過win32 COM打開Excel并添加Sheet的方法
- Python使用win32 COM實(shí)現(xiàn)Excel的寫入與保存功能示例
- Python使用win32com模塊實(shí)現(xiàn)數(shù)據(jù)庫(kù)表結(jié)構(gòu)自動(dòng)生成word表格的方法
相關(guān)文章
python通過微信發(fā)送郵件實(shí)現(xiàn)電腦關(guān)機(jī)
這篇文章主要為大家詳細(xì)介紹了python通過微信發(fā)送郵件實(shí)現(xiàn)電腦關(guān)機(jī),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2018-06-06
Python基于textdistance實(shí)現(xiàn)計(jì)算文本相似度
textdistance是Python的第三方庫(kù),用于計(jì)算文本之間的相似度或距離,本文主要為大家詳細(xì)介紹了如何使用textdistance實(shí)現(xiàn)計(jì)算文本相似度,需要的可以了解下2024-03-03
基于python3 的百度圖片下載器的實(shí)現(xiàn)代碼
這篇文章主要介紹了基于python3 的百度圖片下載器的實(shí)現(xiàn)代碼,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2019-11-11
Python如何使用EasyOCR工具識(shí)別圖像文本
EasyOCR?是?PyTorch?實(shí)現(xiàn)的一個(gè)光學(xué)字符識(shí)別?(OCR)?工具,這篇文章主要介紹了Python如何使用EasyOCR工具識(shí)別圖像文本,需要的朋友可以參考下2023-04-04
python用win32gui遍歷窗口并設(shè)置窗口位置的方法
Django實(shí)現(xiàn)一對(duì)多表模型的跨表查詢方法
python監(jiān)控網(wǎng)卡流量并使用graphite繪圖的示例

