0

我正在尝试部署 InstaPy Bot ( https://github.com/timgrossmann/InstaPy ) Heroku。我的代码如下所示

from instapy import InstaPy
from instapy import smart_run
import time
from datetime import datetime
import schedule

# login credentials
insta_username = 'myUsername'
insta_password = 'myPassword'

# start a session
def get_session():
    session = InstaPy(username=insta_username,
                      password=insta_password,
                      headless_browser=True)
    return session

def likeByTags(tags_to_like, amount_of_likes):
    print("InstaPy LikeByTags Started @ {}".format(datetime.now().strftime("%H:%M:%S")))

    session = get_session()

    with smart_run(session):
        try:
            session.like_by_tags(tags=tags_to_like, amount=amount_of_likes)

        except Exception:
            print(traceback.format_exc())

likeByTags(['natgeo', 'photography'], 5)

如果我在本地运行它,它可以完美运行,但是当我将它部署到 heroku 时,我在 heroku 日志中收到此错误:

2020-08-08T02:06:34.016993+00:00 app[worker.1]: Error, unable to determine correct filename for 64bit linux
2020-08-08T02:06:34.017045+00:00 app[worker.1]: Traceback (most recent call last):
2020-08-08T02:06:34.017046+00:00 app[worker.1]: File "app.py", line 70, in <module>
2020-08-08T02:06:34.017230+00:00 app[worker.1]: likeByTags(['natgeo', 'photography'], 5)
2020-08-08T02:06:34.017236+00:00 app[worker.1]: File "app.py", line 22, in likeByTags
2020-08-08T02:06:34.017400+00:00 app[worker.1]: session = get_session()
2020-08-08T02:06:34.017406+00:00 app[worker.1]: File "app.py", line 16, in get_session
2020-08-08T02:06:34.017590+00:00 app[worker.1]: headless_browser=False)
2020-08-08T02:06:34.017595+00:00 app[worker.1]: File "/app/.heroku/python/lib/python3.6/site-packages/instapy/instapy.py", line 323, in __init__
2020-08-08T02:06:34.017858+00:00 app[worker.1]: self.logger,
2020-08-08T02:06:34.017869+00:00 app[worker.1]: File "/app/.heroku/python/lib/python3.6/site-packages/instapy/browser.py", line 120, in set_selenium_local_session
2020-08-08T02:06:34.018050+00:00 app[worker.1]: driver_path = geckodriver_path or get_geckodriver()
2020-08-08T02:06:34.018051+00:00 app[worker.1]: File "/app/.heroku/python/lib/python3.6/site-packages/instapy/browser.py", line 36, in get_geckodriver
2020-08-08T02:06:34.018194+00:00 app[worker.1]: sym_path = gdd.download_and_install()[1]
2020-08-08T02:06:34.018208+00:00 app[worker.1]: File "/app/.heroku/python/lib/python3.6/site-packages/webdriverdownloader/webdriverdownloader.py", line 177, in download_and_install
2020-08-08T02:06:34.018435+00:00 app[worker.1]: show_progress_bar=show_progress_bar)
2020-08-08T02:06:34.018435+00:00 app[worker.1]: File "/app/.heroku/python/lib/python3.6/site-packages/webdriverdownloader/webdriverdownloader.py", line 129, in download
2020-08-08T02:06:34.018633+00:00 app[worker.1]: download_url = self.get_download_url(version, os_name=os_name, bitness=bitness)
2020-08-08T02:06:34.018639+00:00 app[worker.1]: File "/app/.heroku/python/lib/python3.6/site-packages/webdriverdownloader/webdriverdownloader.py", line 324, in get_download_url
2020-08-08T02:06:34.018894+00:00 app[worker.1]: raise RuntimeError(info_message)
2020-08-08T02:06:34.018937+00:00 app[worker.1]: RuntimeError: Error, unable to determine correct filename for 64bit linux
2020-08-08T02:06:34.110214+00:00 heroku[worker.1]: Process exited with status 1

我读过我必须去webdriverdownloader.py文件并修改一些东西,但这不会影响它在 Heroku 中。那我还应该怎么做?

4

1 回答 1

0

你可以在 Linux 上试试这个:

sudo apt install firefox-geckodriver

其他操作系统,您可以通过安装 geckodriver 来解决此问题 祝您有美好的一天,先生

于 2020-10-31T09:21:49.110 回答