为什么使用PhantomJS时这个特定的URL Selenium无法找到标签,但使用Chromedriver Selenium时可以找到它?
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as ec
from selenium.webdriver.support.ui import WebDriverWait
driver = webdriver.PhantomJS('c:/Users/info_000/AppData/Roaming/npm/node_modules/phantomjs-prebuilt/lib/phantom/bin/phantomjs.exe')
# driver = webdriver.Chrome('E:/Work/IdeaProjects/web_loaders/movie_scraper/chromedriver.exe')
url = 'https://gomovies.to/film/gilmore-girls-a-year-in-the-life-season-1-18045/'
print('opening %s' % url)
driver.get(url)
content = driver.find_element_by_class_name('mvi-cover')
content.click()
print('after click')
src = WebDriverWait(driver, 10).until(
ec.presence_of_element_located((By.TAG_NAME, 'video'))
).get_attribute('src')
答案 0 :(得分:0)
我看到了带有课程的元素' thumb mvi-cover'不是&mv-cover'。
content = driver.find_element_by_class_name('thumb mvi-cover')