I am making a instagram bot for my website using python , selenium and instapy. I have never made something like that with 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.
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
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