1

I deployed flask app using selenium Firefox geckodriver in heroku use this method heroku-integrated-firefox-geckodriver

But I got this error

> 2022-01-13T13:23:47.014999+00:00 app[web.1]: /app/insta/bot.py:37:
> DeprecationWarning: executable_path has been deprecated, please pass
> in a Service object
>     
>     2022-01-13T13:23:47.015013+00:00 app[web.1]:   self.bot = webdriver.Firefox(options=options,executable_path=os.environ.get("GECKODRIVER_PATH"),
> firefox_binary=FirefoxBinary(os.environ.get("FIREFOX_BIN")))
>     
>     2022-01-13T13:23:47.015054+00:00 app[web.1]: /app/insta/bot.py:37: DeprecationWarning: firefox_binary has been deprecated, please pass in
> a Service object
>     
>     2022-01-13T13:23:47.015054+00:00 app[web.1]:   self.bot = webdriver.Firefox(options=options,executable_path=os.environ.get("GECKODRIVER_PATH"),
> firefox_binary=FirefoxBinary(os.environ.get("FIREFOX_BIN")))
>     
>     2022-01-13T13:23:47.522706+00:00 heroku[router]: at=info method=POST path="/instalogin" host=i-bot-1.herokuapp.com
> request_id=6329825e-962c-46c0-834e-d8966a927d29 fwd="42.106.180.246"
> dyno=web.1 connect=0ms service=512ms status=500 bytes=2182
> protocol=https
>     
>     2022-01-13T13:23:47.520605+00:00 app[web.1]: [2022-01-13 13:23:47,519] ERROR in app: Exception on /instalogin [POST]
>     
>     2022-01-13T13:23:47.520615+00:00 app[web.1]: Traceback (most recent call last):
>     
>     2022-01-13T13:23:47.520616+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.9/site-packages/flask/app.py", line
> 2073, in wsgi_app
>     
>     2022-01-13T13:23:47.520616+00:00 app[web.1]:     response = self.full_dispatch_request()
>     
>     2022-01-13T13:23:47.520617+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.9/site-packages/flask/app.py", line
> 1518, in full_dispatch_request
>     
>     2022-01-13T13:23:47.520617+00:00 app[web.1]:     rv = self.handle_user_exception(e)
>     
>     2022-01-13T13:23:47.520618+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.9/site-packages/flask/app.py", line
> 1516, in full_dispatch_request
>     
>     2022-01-13T13:23:47.520618+00:00 app[web.1]:     rv = self.dispatch_request()
>     
>     2022-01-13T13:23:47.520618+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.9/site-packages/flask/app.py", line
> 1502, in dispatch_request
>     
>     2022-01-13T13:23:47.520619+00:00 app[web.1]:     return self.ensure_sync(self.view_functions[rule.endpoint])(**req.view_args)
>     
>     2022-01-13T13:23:47.520619+00:00 app[web.1]:   File "/app/app.py", line 29, in wrap
>     
>     2022-01-13T13:23:47.520620+00:00 app[web.1]:     return f(*args, **kwargs)
>     
>     2022-01-13T13:23:47.520620+00:00 app[web.1]:   File "/app/app.py", line 88, in instalogin
>     
>     2022-01-13T13:23:47.520620+00:00 app[web.1]:     bot = Bot(user)
>     
>     2022-01-13T13:23:47.520621+00:00 app[web.1]:   File "/app/insta/bot.py", line 37, in __init__
>     
>     2022-01-13T13:23:47.520621+00:00 app[web.1]:     self.bot = webdriver.Firefox(options=options,executable_path=os.environ.get("GECKODRIVER_PATH"),
> firefox_binary=FirefoxBinary(os.environ.get("FIREFOX_BIN")))
>     
>     2022-01-13T13:23:47.520622+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.9/site-packages/selenium/webdriver/firefox/webdriver.py",
> line 174, in __init__
>     
>     2022-01-13T13:23:47.520622+00:00 app[web.1]:     self.service.start()
>     
>     2022-01-13T13:23:47.520623+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.9/site-packages/selenium/webdriver/common/service.py",
> line 98, in start
>     
>     2022-01-13T13:23:47.520623+00:00 app[web.1]:     self.assert_process_still_running()
>     
>     2022-01-13T13:23:47.520625+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.9/site-packages/selenium/webdriver/common/service.py",
> line 110, in assert_process_still_running
>     
>     2022-01-13T13:23:47.520626+00:00 app[web.1]:     raise WebDriverException(
>     
>     2022-01-13T13:23:47.520626+00:00 app[web.1]: selenium.common.exceptions.WebDriverException: Message: Service
> /app/vendor/geckodriver/geckodriver unexpectedly exited. Status code
> was: 64

enter image description here

This is my code and this is my selenium code. This code perfectly working in my local computer.

        import os
        from selenium import webdriver
        from selenium.webdriver.firefox.options import Options
        from selenium.webdriver.firefox.firefox_binary import FirefoxBinary            

        options = Options()
        options.headless = True
        options.add_argument("-no-sandbox")
        user_agent = "Mozilla/5.0 (iPhone; U; CPU iPhone OS 3_0 like Mac OS X; en-us) AppleWebKit/528.18 (KHTML, like Gecko) Version/4.0 Mobile/7A341 Safari/528.16"
        options.set_preference("general.useragent.override", user_agent)

        bot = webdriver.Firefox(options=options,executable_path=os.environ.get("GECKODRIVER_PATH"), firefox_binary=FirefoxBinary(os.environ.get("FIREFOX_BIN")))
        bot.set_window_size(500, 950)

I don't know why it's not working. I tried so many another methods but it's not working, please help.

shihar
  • 48
  • 7

0 Answers0