還是老辦法,只是改了個網(wǎng)址,重新分析了發(fā)表的html代碼。
python代碼:
from win32com.client import DispatchEx
import time
ie=DispatchEx("InternetExplorer.Application")
ie.Navigate("http://tieba.baidu.com/f?kw=python")
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"))=="title":
print "Find title"
i.value="AutoCreatedByPython"
break
# editor
for i in body.getElementsByTagName("div"):
if str(i.getAttribute("id"))=="bdeTextArea":
print "Find Content"
break
i.innerHTML="Hello"
# submit
for i in body.getElementsByTagName("input"):
if str(i.getAttribute("id"))=="add_post_submit":
print "Find button"
i.click()
break
不過希望大家別亂運行啊。
閱讀全文
類別:默認分類 查看評論文章來源:
http://hi.baidu.com/mirguest/blog/item/436436f0ba911a00b07ec5d9.html