简体   繁体   中英

Headless Selenium is not extracting data in Python using Chrome driver

While navigating to the page, It is able to extract the data.

Code:

from selenium.webdriver.chrome.options import Options
options1 = Options()
options1.headless = True
driver = webdriver.Chrome(os.getcwd() +"/chromedriver",options = options1)
this is how I am getting the chrome driver 

content = BeautifulSoup(driver.page_source,"html.parser") this is how I am getting the content from the navigated page. While we are navigating to the page able to extract the data.

Can you try it like below?

from selenium import webdriver

options = webdriver.ChromeOptions()
options.add_argument('headless')
driver = webdriver.Chrome(os.getcwd() +"/chromedriver", chrome_options=options)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM