简体   繁体   English

Python:Heroku 在运行时崩溃

[英]Python: Heroku crashes on running instapy

I am making a instagram bot for my website using python, selenium and instapy.我正在使用 python、selenium 和 instapy 为我的网站制作一个 instagram 机器人。 I have never made something like that with Python.我从来没有用 Python 做过这样的事情。

I have installed chrome buildpack and chrome driver in heroku.I read that Instapy has removed the chrome support due to the fact that chrome detects bots frequently.我已经在 heroku 中安装了 chrome buildpack 和 chrome 驱动程序。我读到 Instapy 已经删除了 chrome 支持,因为 chrome 经常检测机器人。

It shows me Following Error.它显示我跟随错误。错误链接。

Bot.py僵尸软件

import os
from instapy import InstaPy
from instapy import smart_run

insta_username = os.environ['INSTA_USER']
insta_password = os.environ['INSTA_PASSWORD']

# get a session!
session = InstaPy(
username=insta_username,
password=insta_password,
headless_browser=True,
)
# let's go! :
with smart_run(session):
# general settings
session.set_relationship_bounds(
    enabled=True,
    potency_ratio=None,
    delimit_by_numbers=True,
    max_followers=6000,
    max_following=3000,
    min_followers=30,
    min_following=30)
session.set_user_interact(
    amount=2, randomize=True, percentage=30, media='Photo')
session.set_do_like(enabled=True, percentage=100)
session.set_do_comment(enabled=True, percentage=5)
session.set_comments([
    'Nice shot! @{}', 'I love your profile! @{}', '@{} Love it!',
    '@{} :heart::heart:', 'Love your posts @{}', 'Looks awesome @{}',
    'Getting inspired by you @{}', ':raised_hands: Yes!',
    '@{}:revolving_hearts::revolving_hearts:', '@{}:fire::fire::fire:',
    'Your feed is an inspiration :thumbsup:',
    'Just incredible :open_mouth:', 'What camera did you use @{}?',
    'Love your posts @{}', 'Looks awesome @{}',
    'Getting inspired by you @{}', ':raised_hands: Yes!',
    'I can feel your passion @{} :muscle:'
],
    media='Photo')

# unfollow activity
session.unfollow_users(
    amount=126,
    nonFollowers=True,
    style="RANDOM",
    unfollow_after=42 * 60 * 60,
    sleep_delay=300)

# follow activity
amount_number = 500
session.follow_user_followers(['chrisburkard', 'danielkordan'],
                              amount=amount_number,
                              randomize=False,
                              interact=True,
                              sleep_delay=240)
""" Joining Engagement Pods...
    """
session.join_pods(topic='general', engagement_mode='no_comments')

Selenium.py Selenium.py

from time import sleep
from selenium import webdriver
from instapy_chromedriver import binary_path
 import os

 browser = webdriver.Chrome(executable_path=binary_path)
 browser.implicitly_wait(5)

 browser.get('https://www.instagram.com/')
 login_link = browser.find_element_by_xpath("//*[contains(text(), 'Log In')]")


 username_input = browser.find_element_by_css_selector("input[name='username']")
 password_input = browser.find_element_by_css_selector("input[name='password']")

 username_input.send_keys("<your username>")
 password_input.send_keys("<your password>")
 login_link.click()
 sleep(2)

 login_button = browser.find_element_by_xpath("//button[@type='submit']")
 login_button.click()
 sleep(5)
 browser.close()

Procfile档案

  web: python3 instabot.py     

Change the version of python in runtime.txt file to 3.9.1 and you may try manually downloading the geckodriver and pushing them to your heroku app via cli....and geckodriver is only for firefox.... modify your program for firefox Change the version of python in runtime.txt file to 3.9.1 and you may try manually downloading the geckodriver and pushing them to your heroku app via cli....and geckodriver is only for firefox.... modify your program for firefox

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM