import timefrom selenium import webdriverfrom selenium.webdriver.support.ui import WebDriverWaitfrom selenium.webdriver.support import expected_conditions as ECfrom mon.by import Bywhile True:# 生成驱动器对象 / Chromechrome_path = r'C:/chromedriver'driver = webdriver.Chrome(executable_path=chrome_path)# 打开QQ空间登陆地址driver.get('')# 登录表单在页面的框架中,所以要切换到该框架driver.switch_to.frame('login_frame')# 显示等待加载class属性faceWebDriverWait(driver, 10).until(EC.presence_of_element_located((By.CLASS_NAME, 'face')))# 查找所有含face属性的a标签trs = driver.find_elements_by_xpath('//div[@id="qlogin_list"]/a[@class="face"]')# 遍历a标签,选中需要登陆的QQ号for tr in trs:QQ = tr.find_element_by_xpath('//span[@id="img_out_88888888"]').get_attribute('uin')if QQ == '88888888':f = tr.find_element_by_xpath('//a[@class="face"]')# 点击登陆f.click()break# 等待页面地址加载出来WebDriverWait(driver, 10).until(EC.url_to_be('https://user./88888888'))# 浏览打开需要刷流量的空间 / 说说driver.get('https://user./7777777/6')driver.execute_script('window.scrollTo(0, document.body.scrollHeight)') # 下拉time.sleep(5)driver.close()time.sleep(5)
100字范文,内容丰富有趣,生活中的好帮手!