Nov-11-2018, 10:28 AM
(Nov-11-2018, 09:46 AM)Larz60+ Wrote: see: https://python-forum.io/Thread-Web-scraping-part-2
search for 'Headless(not loading browser):'
make sure you add options to your code.
this is my new code :
from selenium import webdriver from selenium.webdriver.firefox.options import Options import time #--| Setup options = Options() options.set_headless(headless=True) caps = webdriver.DesiredCapabilities().FIREFOX caps["marionette"] = True browser = webdriver.Firefox(firefox_options=options, capabilities=caps, executable_path=r"C:\Users\root\Desktop\geckodriver.exe") #--| Parse browser.get('https://www.python.org/') time.sleep(2) t = browser.find_element_by_xpath('//*[@id="dive-into-python"]/ul[2]/li[1]/div[1]/pre/code/span[1]') print(t.text) browser.quit()and this is the new error :
Error:Traceback (most recent call last):
File "c:/Users/root/Desktop/token.py", line 10, in <module>
browser = webdriver.Firefox(firefox_options=options, capabilities=caps, executable_path=r"C:\Users\root\Desktop\geckodriver.exe")
File "C:\Python27\lib\site-packages\selenium\webdriver\firefox\webdriver.py", line 164, in __init__
self.service.start()
File "C:\Python27\lib\site-packages\selenium\webdriver\common\service.py", line 95, in start
(os.path.basename(self.path), self.start_error_message, str(e)))
selenium.common.exceptions.WebDriverException: Message: The executable geckodriver.exe needs to be available in the path.
'module' object has no attribute 'system'