2

我正在使用 python、selenium 和 instapy 为我的网站制作一个 instagram 机器人。我从来没有用 Python 做过这样的事情。

我已经在 heroku 中安装了 chrome buildpack 和 chrome 驱动程序。我读到 Instapy 已经删除了 chrome 支持,因为 chrome 经常检测机器人。

它显示我跟随错误。错误链接。

僵尸软件

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')

硒.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()

档案

  web: python3 instabot.py     
4

1 回答 1

1

将runtime.txt文件中的python版本更改为3.9.1,您可以尝试手动下载geckodriver并通过cli将它们推送到您的heroku应用程序......并且geckodriver仅适用于firefox......修改您的firefox程序

于 2020-12-13T15:54:16.200 回答