首先必须是会员才行,因为验证码没有考虑。
# -*- coding:utf-8 -*-
from win32com.client import DispatchEx
import time
def handle(url):
ie=DispatchEx("InternetExplorer.Application")
ie.Navigate(url)
ie.Visible=1
while ie.Busy:
time.sleep(1)
body=ie.Document.body
for i in body.getElementsByTagName("div"):
if str(i.getAttribute("id"))=="bdeTextArea":
print "Find Content"
print i.nodeName
i.click()
break
while ie.Busy:
time.sleep(1)
i.innerHTML="测试".decode("utf-8")
# submit
#for i in body.getElementsByTagName("input"):
# if str(i.getAttribute("id"))=="add_post_submit":
# print "Find button"
# i.click()
# break
ie.quit()
ie=DispatchEx("InternetExplorer.Application")
ie.Navigate("http://tieba.baidu.com/y460")
ie.Visible=1
while ie.Busy:
time.sleep(1)
body=ie.Document.body
for i in body.getElementsByTagName("table"):
if str(i.getAttribute("id"))=="thread_list_table":
tbody=i
break
for i in tbody.getElementsByTagName("tr"):
if str(i.getAttribute("tid")).isdigit():
tmpurl="http://tieba.baidu.com/f?kz=%s"%i.getAttribute("tid")
handle(tmpurl)
ie.quit()
阅读全文
类别:Python 查看评论文章来源:
http://hi.baidu.com/mirguest/blog/item/3f09743a9228e7d1d56225d1.html