marcosschroh / pyinstamation

Easy to use, config oriented, instagram bot, written in python 3
GNU General Public License v3.0
11 stars 2 forks source link
bot instagram instagram-bot python3 selenium

PYINSTAMATION

Easy to use, config oriented, instagram bot, written in python 3

Build Status codecov License: GPL v3

Table of Contents

Features

Quickstart

  1. Check pyvirtualdisplay is installed properly
  2. Create virtualenv
  3. Run:
make init
# set username and password in `config.yaml` and configure at will
make run-bot

API Example

If you want to check how to use the bot in depth check the examples or read the source.

To run the examples just type, but remember to update the constants (user, pass, post url):

python examples/bot_like_and_comment.py

python examples/bot_upload_picture.py

Simple example

from pyinstamation.bot import InstaBot
from pyinstamation.scrapper import InstaScrapper

POST_LINK = 'p/not_a_real_post_id'
USERNAME = 'replace_this_with_your_username'
PASSWORD = 'replace_this_with_your_password'

s = InstaScrapper()
bot = InstaBot(s, username=USERNAME, password=PASSWORD)

bot.start_browser()
bot.login()
bot.like(POST_LINK)
bot.comment(POST_LINK, 'this is a simple comment')
bot.stop()

Prerequisites

OS

Linux (Tested in debian)
OS X

SO Packages

Linux
sudo apt-get install xvfb xserver-xephyr

Python versions

python >3.5
python >2.7  (not supported officially)

Remember to create a virtualenv

Commands

Command Description
make init downloads webdriver and creates a new conf based on the default one
make run-bot starts running the bot (remember to at least set the username and password)
make install-deps installs python dependencies
make start-conf creates a new configuration file with the template from default.config.yaml
make webdriver downloads selenium's webdriver

Configuration

Create a config.yaml and tune it at will, or use make init. The options are divided in different sections.

Option Type Description Default
username * str instagram username to operate. Only username works with statistics, not email ---
password ** str username's password ---
hide_browser bool do not display the browser False
browser_type str browser type (chrome/firefox) chrome

* Required

** Required unless the bot is launched with -p [PASSWORD]

Posts

Option Type Description Default
search_tags str comma separated tags to search for []
ignore_tags str comma separated tags to ignore if a post contains them while searching []
posts_per_day int number of posts to be processed in total, ignored does not count
posts_per_hashtag int number of posts to be processed per hashtag (not recommended)
likes_per_day int maximum likes given in a day 100
like_probability float probability to give a like 0.5
comments_per_day int maximum comments given in a day 10
comment_probability float probability to comment 0.5
comment_enabled bool bot will comment in the searched posts True
comment_generator bool bot will generate a random generic comment True
custom_comments array in case you don't want random comments, you can provide them []

Followers

Option Type Description Default
follow_enable bool while searching the bot will also follow people True
min_followers None or int minimum number followers that a user must have to follow. Lower bound 100
max_followers None or int will follow users with less than this amount of followers. Upper bound 7000
follow_probability float chance to follow someone while searching, between 0 and 1 0.5
ignore_users array users not to follow []
follow_per_day int max number of users to follow 50
unfollow_followed_users bool after a few days the bot will stop following the users followed True

Pics

Option Type Description Default
upload bool when enabled attempts to upload a picture if there is one to upload False
files collection the contents of the files to upload are below []

Pics > files

Option Type Description Default
path * str absolute path to the file location.
datetime str format ISO 8061: %Y-%m-%dT%H:%M:%S eg: 2017-08-18T18:00:00. For now, time is ignored, but the idea is to take it into account None
comment str comment to be added when the pic is posted None

* Required

For config template check default.config.yaml

We told you it was easy.

Running periodically

Use Crontab Use Celery and Celery Beat (with supervisord)

Troubleshooting