之前在锤子便签上写了几百条日记,想用python爬下来,使用selenium.webdriver模拟登录后,在查找元素时总是说未找到,不知道为什么,有没人指导一下?
[Python] 纯文本查看 复制代码 import time
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.support.wait import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
chrome_options = Options()
# chrome_options.add_argument('--headless')
chrome_options.add_argument('--disable-gpu')
driver = webdriver.Chrome(options=chrome_options)
driver.get("https://yun.smartisan.com/#/")
time.sleep(2)
driver.find_element_by_css_selector('#main > div.nosign-view.ng-scope > div.login-btn > span').click()
driver.find_element_by_css_selector('body > div.wrapper.ng-scope > div.dialog.dialog-shadow > div.content.ng-scope.ng-animate > form > ul > li.username.border-1p > div > input').send_keys('账号')
driver.find_element_by_css_selector('body > div.wrapper.ng-scope > div.dialog.dialog-shadow > div.content.ng-scope.ng-animate > form > ul > li.password > div > input').send_keys('密码')
driver.find_element_by_css_selector('body > div.wrapper.ng-scope > div.dialog.dialog-shadow > div.content.ng-scope.ng-animate > form > div.btn-wrapper > div > a').click()
driver.find_element_by_css_selector('#main > div.cloud-view.ng-scope > a:nth-child(2) > div.cd-icon.notes-app-icon').click()
wait = WebDriverWait(driver, 30)
element = wait.until(EC.visibility_of_element_located((By.CLASS_NAME, "ng-scope")))
# driver.implicitly_wait(5)
print(driver.find_element_by_css_selector('#noten198t1580278052580 > div.note-status > div.time.ng-binding'))
# driver.find_element_by_xpath('//*[@id="editor"]/div/div[6]/div[1]/div/div/div/div[5]/pre/span/text()')
# print(find_element_by_css_selector('body > div.wrapper > div.note-right > div.edit-wrap.ng-scope > div.edit-con > div.edit-wrap-scroller.ps-container.ps-theme-default.ps-active-y'))
driver.close()
driver.quit() |