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實(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ù)庫表結(jié)構(gòu)自動生成word表格的方法
相關(guān)文章
python實(shí)現(xiàn)微信跳一跳輔助工具步驟詳解
這篇文章主要介紹了python實(shí)現(xiàn)微信跳一跳輔助工具的步驟詳解以及使用說明,需要的朋友可以參考下2018-01-01python在前端頁面使用?MySQLdb?連接數(shù)據(jù)
這篇文章主要介紹了MySQLdb?連接數(shù)據(jù)的使用,文章主要介紹的相關(guān)內(nèi)容又插入數(shù)據(jù),刪除數(shù)據(jù),更新數(shù)據(jù),搜索數(shù)據(jù),需要的小伙伴可以參考一下2022-03-03Python設(shè)計模式之橋接模式原理與用法實(shí)例分析
這篇文章主要介紹了Python設(shè)計模式之橋接模式原理與用法,結(jié)合具體實(shí)例形式分析了Python橋接模式的相關(guān)概念、原理、定義及使用方法,需要的朋友可以參考下2019-01-01Python利用subplots_adjust方法解決圖表與畫布的間距問題
這篇文章主要介紹了如何在使用python?的?matplotlib庫繪圖時,?使用subplots_adjust()方法來調(diào)整圖表與畫布之間的間距,以及圖表與圖表之間的間距,感興趣的可以了解一下2022-04-04python基礎(chǔ)教程之基本內(nèi)置數(shù)據(jù)類型介紹
在Python程序中,每個數(shù)據(jù)都是對像,每個對像都有自己的一個類型。不同類型有不同的操作方法,使用內(nèi)置數(shù)據(jù)類型獨(dú)有的操作方法,可以更快的完成很多工作2014-02-02