还是老办法,只是改了个网址,重新分析了发表的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