Apr-24-2020, 12:22 PM
Try find tag bye CSS selector or xPath.
Shorting class name did work for my,here a demo of both.
Shorting class name did work for my,here a demo of both.
from selenium import webdriver from selenium.webdriver.chrome.options import Options #--| Setup options = Options() options.add_argument("--headless") options.add_argument("window-size=1024,960") browser = webdriver.Chrome(executable_path=r'C:\cmder\bin\chromedriver.exe', options=options) #--| Parse or automation browser.get('file:///E:/div_code/scrape/local.html') text = browser.find_element_by_class_name('explorer__titlesegment').text text_selector = browser.find_elements_by_css_selector('body > span')[0].text print(text) print(text_selector)
Output:Brokerage Account
Brokerage Account
local.html
that i test with.<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>Title of the document</title> </head> <body> <span class="explorer__titlesegment explorer__titlesegment--type">Brokerage Account</span> </body> </html>