随笔 - 41, 文章 - 8, 评论 - 8, 引用 - 0
数据加载中……

[导入][python]使用python在贴吧发帖

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

posted on 2011-02-07 12:22 mirguest 阅读(511) 评论(0)  编辑 收藏 引用


只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理