shaikhsajid1111 / facebook_page_scraper

Scrapes facebook's pages front end with no limitations & provides a feature to turn data into structured JSON or CSV
https://pypi.org/project/facebook-page-scraper/
MIT License
211 stars 63 forks source link

selenium.common.exceptions.SessionNotCreatedException - Issues with GeckoDriver #4

Closed gohjiayi closed 3 years ago

gohjiayi commented 3 years ago

Hi, thanks for the codes! Was trying to test this package out and faced this issue when running the sample codes in the README. I am not very familiar with web scraping but seems to be some issue with GeckoDriver, not too sure on why this error is popping out. Besides that, I would like to also check if this package works with Facebook groups (not pages). Please help!

>>> json_data = facebook_ai.scrap_to_json()
[WDM] - Driver [C:\Users\Jiayi\.wdm\drivers\geckodriver\win64\v0.29.0\geckodriver.exe] found in cache
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Users\Jiayi\Documents\GitHub\facebook_page_scraper\facebook_page_scraper\scraper.py", line 56, in scrap_to_json
    self.__start_driver()
  File "C:\Users\Jiayi\Documents\GitHub\facebook_page_scraper\facebook_page_scraper\scraper.py", line 52, in __start_driver
    self.__driver = Initializer(self.browser).init()
  File "C:\Users\Jiayi\Documents\GitHub\facebook_page_scraper\facebook_page_scraper\driver_initialization.py", line 48, in init
    driver = self.set_driver_for_browser(self.browser_name)
  File "C:\Users\Jiayi\Documents\GitHub\facebook_page_scraper\facebook_page_scraper\driver_initialization.py", line 42, in set_driver_for_browser
    return webdriver.Firefox(executable_path=GeckoDriverManager().install(),options=self.set_properties(browser_option))
  File "C:\Users\Jiayi\AppData\Local\Programs\Python\Python38\lib\site-packages\selenium\webdriver\firefox\webdriver.py", line 170, in __init__
    RemoteWebDriver.__init__(
  File "C:\Users\Jiayi\AppData\Local\Programs\Python\Python38\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 157, in __init__
    self.start_session(capabilities, browser_profile)
  File "C:\Users\Jiayi\AppData\Local\Programs\Python\Python38\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 252, in start_session
    response = self.execute(Command.NEW_SESSION, parameters)
  File "C:\Users\Jiayi\AppData\Local\Programs\Python\Python38\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 321, in execute
    self.error_handler.check_response(response)
  File "C:\Users\Jiayi\AppData\Local\Programs\Python\Python38\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 242, in check_response       
    raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.SessionNotCreatedException: Message: Expected browser binary location, but unable to find binary in default location, no 'moz:firefoxOptions.binary' capability provided, and no binary flag set on the command line
shaikhsajid1111 commented 3 years ago

There are some possible reasons for that error like:

Currently, it scrapes only Facebook pages. Soon, will add the feature for public groups as well.

gohjiayi commented 3 years ago

Thanks for your help, can I ask if this applies to Firefox only? Since I do have chrome installed and I assumed it will work with that...

shaikhsajid1111 commented 3 years ago

Yeah it will, just replace "firefox" with "chrome"

gohjiayi commented 3 years ago

Got it! Thanks for your help, hope to see the new feature for public groups soon. 👍🏻