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在前端頁面使用?MySQLdb?連接數(shù)據(jù)
這篇文章主要介紹了MySQLdb?連接數(shù)據(jù)的使用,文章主要介紹的相關(guān)內(nèi)容又插入數(shù)據(jù),刪除數(shù)據(jù),更新數(shù)據(jù),搜索數(shù)據(jù),需要的小伙伴可以參考一下2022-03-03Python利用subplots_adjust方法解決圖表與畫布的間距問題
這篇文章主要介紹了如何在使用python?的?matplotlib庫繪圖時,?使用subplots_adjust()方法來調(diào)整圖表與畫布之間的間距,以及圖表與圖表之間的間距,感興趣的可以了解一下2022-04-04python基礎教程之基本內(nèi)置數(shù)據(jù)類型介紹
在Python程序中,每個數(shù)據(jù)都是對像,每個對像都有自己的一個類型。不同類型有不同的操作方法,使用內(nèi)置數(shù)據(jù)類型獨有的操作方法,可以更快的完成很多工作2014-02-02