Coder Social home page Coder Social logo

cipz / instagrambots Goto Github PK

View Code? Open in Web Editor NEW
0.0 2.0 0.0 7.18 MB

This repo is a collection of simple Instagram bots that automatically scrap the web, generate an image and post it on Instagram every now and then.

Python 86.57% TeX 11.85% Dockerfile 1.58%
instagram bot python3

instagrambots's Introduction

Instagram Bots

This repository contains a few python scripts that act as Instagram bots that scrape the Internet for interesting daily / weekly content. It is not intended as a serious repository, it was created of of boredom and just for fun / entrataining reasons.

Sometimes they stop and the accounts need a password change since Facebook / Meta / Instagram does not like bots posting on their platform. So there might be "service interruptions" from time to time.

The bots

Here is a list of the bots currently present in this repo:

How it works

The core of this project is web scraping. Given a particular web page, each bot has the same behaviour:

  1. it downloads the page
  2. searches for the content in the page (text or image), possibly downloading it from other pages
  3. a Latex file is compiled in order to create a square pdf (7cm x 7cm) which is then converted in jpg
  4. sets the caption of the image and the hashtags
  5. connects to Instagram and posts the picture with the caption

Each script can be executed by calling it inside it's folder (e.g. python3 the_new_yorker.py). The -d or --debug argument can be used to test the script locally and avoid it posting on Instagram. The requirements.txt file contains the python dependencies.

Github Actions

In order to execute the scripts daily I have created a cron job in Github actions to execute all the bots. This can be done in a more granular way, which means having a yml file for each script, but the initialization of the docker container used to compile the Latex files takes to much time compared to having them all execute together.

Libraries and other dependencies

Here is a list of the main libraries used in this project:

Instagram API library

Currently, the Instagram API library used is instagrapi. Such library contains API wrappers that have been reverse-engineered, thus not guaranteeing they will work forever.

Latex figure creation and Docker container

A custom Docker container is initialized to execute the scripts. This detaches the whole project from GitHub Action's containers and environments, allowing for better portability of the project (e.g. it can be executed the container even on a Raspberry Pi).

Limitations

Unfortunately the Facebook team (who currently owns Instagram, among a thousand other things), does not like bots and other automated scripts that mess around with their data, so they frequently change APIs and block requests from third party libraries. igbot and other libraries such as instagram_private_api are currently being blocked or not up to date with the APIs from FB.

Improvements and possible future work

As said before, this repository is not intended as a too serious work, just a time-filling fun activity that allowed me to get acquainted with Instagram's APIs and other APIs from sites as Spotify, Google Trends and YouTube (even thouth there are no bots for them... yet!).

There are many improvements that can be done, here are just a few:

  • avoid the use of Latex and use the PIL library to automatically generate the square images
  • notification system when the bots fail
  • badges with the latest post from each bot
  • add Instagram stories and post videos
  • make more granular yml workflow files, possibly one for each python script

License

MIT

Author

Ciprian Voinea

instagrambots's People

Contributors

actions-user avatar cipz avatar

Watchers

 avatar  avatar

instagrambots's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.