I have a web app that needs to do a bit of web-scraping. I am trying to use Selenium or Splinter, but I seem to keep running into problems.
With Splinter, my code looks like this:
from pyvirtualdisplay import Display
from splinter import Browser, driver
display = Display(visible=0, size=(800, 600))
display.start()
for retry in range(3):
try:
browser = Browser("firefox")
break
except Exception as e:
print("Failed to start browser [%s]" % e)
time.sleep(3)
The output looks like this:
Failed to start browser [Message: The browser appears to have exited before we could connect. If you specified a log_file in the FirefoxBinary constructor, check it for details.#012]
Failed to start browser [Message: The browser appears to have exited before we could connect. If you specified a log_file in the FirefoxBinary constructor, check it for details.#012]
Failed to start browser [Message: The browser appears to have exited before we could connect. If you specified a log_file in the FirefoxBinary constructor, check it for details.#012]
With Selenium, my code looks like this:
from pyvirtualdisplay import Display
from selenium import webdriver
display = Display(visible=0, size=(800, 600))
display.start()
for retry in range(3):
try:
driver = webdriver.Firefox()
print("Successfully got webdriver.Firefox()")
break
except Exception as e:
print("%s" % e)
time.sleep(2)
And the output looks like this:
Message: The browser appears to have exited before we could connect. If you specified a log_file in the FirefoxBinary constructor, check it for details.
Message: The browser appears to have exited before we could connect. If you specified a log_file in the FirefoxBinary constructor, check it for details.
Message: The browser appears to have exited before we could connect. If you specified a log_file in the FirefoxBinary constructor, check it for details.