在线观看不卡亚洲电影_亚洲妓女99综合网_91青青青亚洲娱乐在线观看_日韩无码高清综合久久

鍍金池/ 問答/Python/ webdrive www2.baidu.com 定位不到元素

webdrive www2.baidu.com 定位不到元素

#coding:utf-8
from selenium import webdriver
import time,os,sys

def withoutCookieLogin(url):
    options = webdriver.ChromeOptions()
    driver = webdriver.Chrome(chrome_options=options)
    options.add_argument('lang=zh_CN.UTF-8')
    options.add_argument("user-agent='Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.181 Safari/537.36'")
    driver.maximize_window()
    driver.get(url)
    driver.find_element_by_class_name('tab-log-type pull-right').click()
    driver.find_element_by_id('uc-common-account').clear()
    driver.find_element_by_id('uc-common-account').send_keys("name")
    driver.find_element_by_id('ucsl-password-edit').clear()
    driver.find_element_by_id('ucsl-password-edit').send_keys("password")
    authCode = input('輸入驗證碼')
    driver.find_element_by_id('uc-common-token').send_keys(authCode)
    driver.find_element_by_id(u'submit-form').click()
    return driver

driver = withoutCookieLogin("http://cas.baidu.com/?tpl=www2&fromu=http%3A%2F%2Fwww2.baidu.com%2F")`請輸入代碼`

其他網(wǎng)站都沒問題,鳳巢后臺搜尋不到element,有注意到打開的chrome瀏覽器是看不到element,右鍵對body進行edit as html,然后才能看到,python新手,求大手子指教,感謝!

圖片描述

回答
編輯回答
蔚藍色

感謝指證 另外不僅是第一個錯誤 下面的element也都是找不到的

2017年11月26日 20:35
編輯回答
誮惜顏

注意報錯“Compound class names not permitted”,多個class是不被允許的,調(diào)用find_element_by_class_name()只接受一個class。
可以用xpath替代,這樣寫:

driver.find_element_by_xpath("http://*[@class='tab-log-type' or @class='pull-right']")
2017年9月13日 19:56