0
私は、エラーの下に取得していますコードそのような要素ません:要素を見つけることができません:
import time
from selenium import webdriver
driver = webdriver.Chrome()
driver.get(html_page)
driver.find_element_by_xpath("""//*[@id="bv-hero-ALL-LIFE-INSURANCE"]/span[2]/span[2]""").click()
driver.implicitly_wait(20)
reviews_list = driver.find_elements_by_css_selector('bv-content-item bv-content-top-review bv-content-review')
author = ''
summary = ''
product_family = ''
for div in driver.find_element_by_xpath('//*[@id="BVRRContainer"]/div/div/div/div/ol'):
try:
author = div.find_element_by_xpath('//*[@id="BVRRContainer"]/div/div/div/div/ol/li[1]/div[2]/div[1]/div/div[1]/div/div[1]/div/div/div/h3').text
summary = div.find_element_by_xpath('//*[@id="BVRRContainer"]/div/div/div/div/ol/li[1]/div[2]/div[1]/div/div[2]/div/div/div[1]/p/text()').text
product_family = div.find_element_by_xpath('//*[@id="BVRRContainer"]/div/div/div/div/ol/li[1]/div[2]/div[1]/div/div[2]/div/div/div[2]/div[3]/div/span/a').text
except Exception:
print(Exception)
if author and summary and product_family:
single_item_info = {
'author': author.encode('UTF-8'),
'summary': summary.encode('UTF-8'),
'insurance type': product_family.encode('UTF-8')
}
print(single_item_info)
driver.quit()
の下に使用してhttps://www.tiaa.org/public/offer/products/life-insuranceのレビューの内容をこすりしようとしています。指導してください。 id = BVRRContainer
と
selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"xpath","selector":"//*[@id="BVRRContainer"]/div/div/div/div/ol"}
(Session info: chrome=57.0.2987.133)
(Driver info: chromedriver=2.29.461591 (62ebf098771772160f391d75e589dc567915b233),platform=Windows NT 6.3.9600 x86_64)
感謝する前にこれを行う、これはiframeにフォーカスを切り替えるには!その働く.. – venkat