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 "タイトルを検索"
i.value="AutoCreatedByPython"
ブレーク
# editor
for i in body.getElementsByTagName("iframe"):
print "Find iframe"
if str(i.getAttribute("id"))=="tangram_editor_iframe_TANGRAM__1":
print "検索"
Break
iframe=i
iframe.click()
sondoc=iframe.contentWindow.Document;
print Sondoc
sonbody=sondoc.body
printsonbody
for ii insonbody.getElementsByTagName("p"):
print "Find p"
ii.innerHTML="こんにちは、初めての試みです"
tmp=sondoc.createElement(" div")
tmp.innerHTML="bye"
sonbody.insertBefore(tmp,ii)
tmpHTML="
# submit
for i in body.getElementsByTagName("div"):
if str(i.getAttribute("id"))=="btn-box":
print "検索ボタン"
休憩
btnbox=i
j=btnbox.childNodes(0)
j.click()