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簡單方法(必看)
- python使用win32com庫播放mp3文件的方法
- Python使用win32com實現(xiàn)的模擬瀏覽器功能示例
- 使用Python通過win32 COM實現(xiàn)Word文檔的寫入與保存方法
- 使用Python通過win32 COM打開Excel并添加Sheet的方法
- Python使用win32 COM實現(xiàn)Excel的寫入與保存功能示例
- Python使用win32com模塊實現(xiàn)數(shù)據(jù)庫表結(jié)構(gòu)自動生成word表格的方法
相關(guān)文章
python通過微信發(fā)送郵件實現(xiàn)電腦關(guān)機
這篇文章主要為大家詳細介紹了python通過微信發(fā)送郵件實現(xiàn)電腦關(guān)機,具有一定的參考價值,感興趣的小伙伴們可以參考一下2018-06-06
Python基于textdistance實現(xiàn)計算文本相似度
textdistance是Python的第三方庫,用于計算文本之間的相似度或距離,本文主要為大家詳細介紹了如何使用textdistance實現(xiàn)計算文本相似度,需要的可以了解下2024-03-03
python用win32gui遍歷窗口并設(shè)置窗口位置的方法
python監(jiān)控網(wǎng)卡流量并使用graphite繪圖的示例

