关键在于以下两行代码 特别是find_element_by_xpath写法 很多写成 findElementsByXpath不知道是写错了 还是高级版本是这么写的...
#webElement = self.dr.find_element_by_xpath("//*");
#print(webElement.get_attribute("outerHTML"))
import os
from selenium import webdriver
import time
class Firefox_webdriver:
dr=webdriver.Chrome()
def autosend(self,my_username,my_password,interval,num):
self.dr.get("http://cas.baidu.com/?tpl=www2&fromu=http%3A%2F%2Fwww2.baidu.com%2F")
self.dr.implicitly_wait(1)
time.sleep(40)
#self.dr.find_element_by_id("TANGRAM__3__userName").send_keys("xxx@qq.com")
#self.dr.find_element_by_id("TANGRAM__3__password").send_keys("xxx")
#self.dr.find_element_by_name("pass-button pass-button-submit").click()
#self.dr.find_element_by_id("TANGRAM__3__submit").click()
#time.sleep(5)
self.dr.get("http://fengchao.baidu.com/nirvana/main.html?userid=5365496&%20%20userid=5365496&t=1397266614555&castk=62a4dmj7728a3a6aed231#/~pkgId=5&target=aoPk%20%20g")
time.sleep(30)
webElement = self.dr.find_element_by_xpath("//*");
print(webElement.get_attribute("outerHTML"))
'''for i in range(1,num):
url="http://test2.tieba.baidu.com/d/c/addPost?gid=258&content="+str(i)+"&sign=*****"
self.dr.get(url)
time.sleep(interval)
#self.dr.close()
'''
if __name__ == "__main__":
browser = Firefox_webdriver()
browser.autosend("*****","****",2,10)