Code Monkey home page Code Monkey logo

b31ngd3v / myigbot Goto Github PK

View Code? Open in Web Editor NEW
171.0 13.0 40.0 258 KB

MyIGBot is a Private API for Instagram to like, follow, comment, view & intaract with stories, upload post & stories, get all information about a user/posts and get posts based on locations/hashtags. It also supports proxy.

Home Page: https://pypi.org/project/myigbot/

License: MIT License

Python 100.00%
instagram instagram-bot ig-bot api instagram-api private-api ig-private-api story ig-story python

myigbot's Introduction

MyIGBot  Build Status

MyIGBot is a Instagram Private API to like, follow, comment, view & intaract with stories, upload post & stories, get all information about a user/posts and get posts based on locations/hashtags.

  • Easy to use
  • More Powerful Now
  • 2FA Login Support

New Features!

  • Get information of a user/post.
  • Get posts based on hashtag/location.
  • It also supports proxy now.
  • Added 35+ features on this update.

You can also:

  • Send Story Views
  • Like, Unlike, Comment in a Post
  • Follow, Unfollow User
  • Upload Post and Stories
  • Intaract with Stories
  • Cookie Storing Feature

Tech

MyIGBot uses a number of open source projects to work properly:

  • Python - Python is an interpreted, high-level and general-purpose programming language
  • Requests - to make HTTP requests simpler
  • BeautifulSoup - is a Python package for parsing HTML and XML documents.

And of course MyIGBot itself is open source with a public repository on GitHub.

Installation

Place myigbot.py and utils.py in the same folder where your project is. (recommended)

or,

Install MyIGBot from PyPi (out of date)

$ pip install myigbot

Usage

Here is how to use MyIGBot (you can also check usage.py)

Login Process (if your account has 2 Factor Auth. The bot will ask you the code.)
from myigbot import MyIGBot

bot = MyIGBot('USERNAME', 'PASSWORD')
Like post
response = bot.like('https://www.instagram.com/p/CH5qV6-so6Y/')
print(response)  # if the response code is 200 that means ok
Unlike post
response = bot.unlike('https://www.instagram.com/p/CH5qV6-so6Y/')
print(response)  # if the response code is 200 that means ok
Like Recent post
response = bot.like_recent('instagram')
print(response)  # if the response code is 200 that means ok
Comment on post
response = bot.comment('https://www.instagram.com/p/CH5qV6-so6Y/', comment_text='Nice Post!')
print(response)  # if the response code is 200 that means ok
Comment on recent post
response = bot.comment_recent('instagram', comment_text='Nice Post!')
print(response)  # if the response code is 200 that means ok
Follow user
response = bot.follow('instagram')
print(response)  # if the response code is 200 that means ok
Unfollow user
response = bot.unfollow('instagram')
print(response)  # if the response code is 200 that means ok
Send story view
response = bot.story_view('b31ngdev')
print(response)  # if the response code is 200 that means ok
Upload post
response = bot.upload_post('image.png', caption='Image 1')
print(response)  # if the response code is 200 that means ok
Upload Story
response = bot.upload_story('image2.png')
print(response)  # if the response code is 200 that means ok
Find posts with hashtags
response = bot.hashtag_posts('programmershumor', limit=50)
print(response)  # by default the limit is setted to 20, this is a optional parameter
Find posts with location
response = bot.location_posts('https://www.instagram.com/explore/locations/6889842/paris-france/', limit=20)
print(response)  # by default the limit is setted to 20, this is a optional parameter
User post count
response = bot.user_posts_count('instagram')
print(response)
User follower count
response = bot.user_followers_count('instagram')
print(response)
User follow count
response = bot.user_follow_count('instagram')
print(response)
Post like count
response = bot.like_count('https://www.instagram.com/p/CH5qV6-so6Y/')
print(response)
Post comment count
response = bot.comment_count('https://www.instagram.com/p/CH5qV6-so6Y/')
print(response)
Get every post's link of a user
response = bot.user_posts('instagram', limit=50)
print(response)  # by default the limit is setted to 50, this is a optional parameter
List of username who followed the user
response = bot.user_followers('instagram', limit=50)
print(response)  # by default the limit is setted to 50, this is a optional parameter
List of username whom the user follows
response = bot.user_follows('instagram', limit=50)
print(response)  # by default the limit is setted to 50, this is a optional parameter
List of username who liked a post
response = bot.post_likers('https://www.instagram.com/p/CH5qV6-so6Y/', limit=50)
print(response)  # by default the limit is setted to 50, this is a optional parameter
List of username who commented a post
response = bot.post_commenters('https://www.instagram.com/p/CH5qV6-so6Y/', limit=50)
print(response)  # by default the limit is setted to 50, this is a optional parameter
Feed posts of logged in user
response = bot.feed_posts()
print(response)
Username of the post owner
response = bot.post_owner('https://www.instagram.com/p/CH5qV6-so6Y/')
print(response)
Get caption of a post
response = bot.post_caption('https://www.instagram.com/p/CH5qV6-so6Y/')
print(response)
Get location of a post
response = bot.post_location('https://www.instagram.com/p/CH5qV6-so6Y/')
print(response)
Get hashtags used in the post
response = bot.post_hashtags('https://www.instagram.com/p/CH5qV6-so6Y/')
print(response)
Get usernames who are tagged in a post
response = bot.post_tagged_user('https://www.instagram.com/p/B2fZRgBA2wj/')
print(response)
Get HD quality Profile Picture download link
response = bot.user_dp('instagram')
print(response)
Get bio of a user
response = bot.user_bio('instagram')
print(response)
Find the account is private or not
response = bot.private_user('instagram')
print(response)
Find the account is verified or not
response = bot.verified_user('instagram')
print(response)
Get external url of a username
response = bot.user_external_url('instagram')
print(response)
Find the user follows you or not
response = bot.follows_me('instagram')
print(response)
Find you follow the user or not
response = bot.followed_by_me('instagram')
print(response)
Get video views count
response = bot.video_views_count('https://www.instagram.com/p/B2XPNNvgApx/')
print(response)
Get post type (video or picture)
response = bot.post_type('https://www.instagram.com/p/CH5qV6-so6Y/')
print(response)
Get exact time when the post was posted
response = bot.post_time('https://www.instagram.com/p/CH5qV6-so6Y/')
print(response)

Proxy

Here is how to add proxy

Method For Authenticated Proxies

from myigbot import MyIGBot

proxies = {
    'http': 'user:pass@host:port',
    'https': 'user:pass@host:port'
}
bot = MyIGBot('USERNAME', 'PASSWORD', proxy=proxies)

Method For Non-Authenticated Proxies

from myigbot import MyIGBot

proxies = {
  'http': 'host:port',
  'https': 'host:port',
}
bot = MyIGBot('USERNAME', 'PASSWORD', proxy=proxies)

License

OpenSource        MIT

Free Software, Hell Yeah!

myigbot's People

Contributors

animemoeus avatar b31ngd3v avatar el-pr0f3ss0r avatar gupta-anubhav12 avatar miguelo981 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

myigbot's Issues

Login Failed !

I have this issue
←[91m[✗] Login Failed!←[0m {"user": true, "authenticated": false, "status": "ok"}
The first time is OK
but the second one I try and fail. I tried on change proxy but the issue still exists.

suspicious login attempt blocked

Traceback (most recent call last):
  File "/Users/xxx/MyIGBot/usage.py", line 3, in <module>
    bot = MyIGBot('correct-username', 'correct-password')
  File "/Users/xxx/MyIGBot/myigbot.py", line 178, in __init__
    self.sessionid = login_response.headers['Set-Cookie'].split('sessionid=')[1].split(';')[0]                
IndexError: list index out of range

I get this error, I am not sure what to do. Help will be appreciated.

Update:
the error disappeared, now it says login failed. instagram sent me a mail saying suspicious login blocked. need a workaround on this,

Suspicious login attempt

Even the simplest bot would not work as the login would fail due to instagram detecting a suspicious login attempt and requiring verification. Even after verifying the warning, it would still block out the bot every time. What should I do? I have tried logging in using incognito, verifying, and starting up the bot, but this did not fix the issue. Does the bot not work anymore?

from myigbot import MyIGBot

bot = MyIGBot( "", "")

response = bot.upload_post('testing.png', caption='Image 1')
print(response) 

EDIT: I tried adding a 2 Factor Authentication to my account, but it still raises the suspi cious login warning, and gives me this error now:


Traceback (most recent call last):
  File "C:\Users\\Desktop\Personal Work\\.....\\", line 4, in <module>
    bot = MyIGBot('', '')
  File "C:\Users\...\AppData\Local\Programs\Python\Python38\lib\site-packages\myigbot\__init__.py", line 178, in __init__
    self.sessionid = login_response.headers['Set-Cookie'].split('sessionid=')[1].split(';')[0]
IndexError: list index out of range

Login Failed

no matter wich account i use it says :
[✗] Login Failed!
i already tested three ig accounts and with or without proxies

Getting 403 error when login

Hello, I have been working with ur API, and when I am trying to log in with correct user credentials I am getting 403 error, what does it mean?

Add a function to post videos

Just a suggestion, it would be greatly appreciated and separate this repo from the other ones aside from how easy it is to use :)

add return spam

please add error handling when returning json smap {"message": "", "spam": true, "status": "fail"}

eg try follow_count = json.loads (response) ['graphql'] ['user'] ['edge_follow'] ['count']
except

follow_count = json.loads (response) ['spam']

csrftoken

Whenever i try to login to the account, it returns: 'csrftoken'

from myigbot import MyIGBot

bot = MyIGBot('random.dog.daily', 'Password')

Any Help? Sorry if im being dumb

ModuleNotFoundError: No module named 'cv2' (Details Below)

Traceback (most recent call last):
File "c:\Users\USERNAME\Desktop\MyIGBot-main\try1.py", line 1, in
from myigbot import MyIGBot
File "c:\Users\USERNAME\Desktop\MyIGBot-main\myigbot.py", line 10, in
from utils import get_media_duration
File "c:\Users\USERNAME\Desktop\MyIGBot-main\utils.py", line 1, in
import cv2
ModuleNotFoundError: No module named 'cv2'

"post_likers" function returns incorrect amount of likers on a post

Hi there,

The post_likers function does not return the exact amount of likers on any post with more than 128 likes.

post = "https://www.instagram.com/p/CDbt2ikF2q9/"

like_count = bot.like_count(post)
print(like_count)
response = bot.post_likers(post, limit=like_count)
print(len(response))

returns:

841
504

Really enjoy the bot you've written so far - nice work!

KeyError: 'upload_id'

File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/myigbot/init.py", line 696, in upload_post
upload_id = json_data['upload_id']
KeyError: 'upload_id'

información perfiles privado o perfiles publicos que no aceptan que los etiqueten

Thanks, Thanks this app is very good

looking at myigbot.py there is the functions:
private_user
and verified_user

1.- to see if the private profile returns to me and it does not.

2.- there are public profiles that they configured not to be tagged ..

this can block us and the app

A function that returns users that do not allow to be tagged, do not allow to be commented

Upload multiple image posts

I couldn't find anything in the code that indicated it was possible. Maybe I'm doing something wrong?

Also couldn't find any possible documentation on doing this.

Thanks

Login Not Working

KeyError: "name='csrftoken', domain=None, path=None"

just tried to login and this error came up

from myigbot import MyIGBot

bot = MyIGBot('xxx', 'xxx')

CSRF Token is missing when logging in

Traceback (most recent call last):
self.csrf_token = cookie_jar['csrftoken']
KeyError: 'csrftoken'

response.cookies is empty and therefore the csrftoken cannot be extracted.
I tried it with proxies, as well, but that still didn't solve it.

It seems like IG changed something on their end once again.
I have tried other active instagram libraries from github as well. Always same result.

Error 403 in Like

Hello, I am trying to like a post with my account and leave a comment, but I receive a 403 error.
my code:

from myigbot import MyIGBot
 
bot = MyIGBot('maryam85rr', '********')

a = bot.like('https://www.instagram.com/p/CUp8_KbNnDe/?utm_source=ig_web_copy_link')

b = bot.comment('https://www.instagram.com/p/CUp8_KbNnDe/?utm_source=ig_web_copy_link','nice')

print(b)

print(a)`

terminal:
403
403

Discussion about Instagram Rate limits (using story_view function)

First of all, thanks @b31ngd3v for building this API.
I recently built a quick script to view accounts' stories in loop. Here's the code

from myigbot import MyIGBot
import time
import random

bot = MyIGBot(username,pw)

storiesCount = 0

def getLastMediaLikers(account):

    # Try to get a list of users that liked the account's last post. If the account has no posts or it's private, return []

    try:
        getMedias = bot.user_posts(account)
        if getMedias == []: return []

        getLikers = bot.post_likers(getMedias[0])
        print(f"Got {len(getLikers)} media likers for the account {account}")
        return getLikers
    except:
        return [] # If anything goes wrong, return an empty list

def storyView(account):
    global storiesCount

    # Attempt to view the story of the account. If successful, increment storiesCount

    try:
        print("Attempting story view for",account)
        if bot.story_view(account) == 200: storiesCount += 1
        print(f"Current stories count: {storiesCount}")
        time.sleep(2.5)
    except:
        pass # In case something goes wrong
    return
  
currentAccount = input("Please provide an account to start from")
likers = getLastMediaLikers(currentAccount)

while True:

    # View the story of currentAccount and all the one of the first 50 likers of its last post. Then choose a random account and repeat.

    storyView(currentAccount)
    for a in likers:
        storyView(a)
    currentAccount = random.choice(likers)
    likers_sub = getLastMediaLikers(currentAccount)
    while likers_sub == []:
        currentAccount = random.choice(likers)
        likers_sub = getLastMediaLikers(currentAccount)
    likers = likers_sub
    print("Current account:",currentAccount,". Long Sleeping.")
    time.sleep(5)

After a few minutes, my script gets detected and I'm required to change my instagram password due to "a suspiscious login attempt". Does anyone know what IG's rate limits are & what my sleep times should be in order not to run into this?

Login Failed

I did this steps:

  1. pip install myigbot
  2. write this to a python file
from myigbot import MyIGBot
bot = MyIGBot('usrname', 'pass')  # Login Information (if you're account has 2 Factor Auth. The Bot Will Ask You The Code.)
a=bot.like('https://www.instagram.com/p/CHqtHbkB6KE/')
print(a)

but unfortunately

←[91m[✗] Login Failed!←[0m

this error occured.
What's wrong?

Not working on the VPS

>>> from myigbot import MyIGBot
>>> bot = MyIGBot('username','password')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/tendean/repositories/animemoeus/telegram_bot/myigbot/myigbot.py", line 36, in __init__
    csrf = response.cookies['csrftoken']
  File "/home/tendean/virtualenv/repositories/animemoeus/3.7/lib/python3.7/site-packages/requests/cookies.py", line 328, in __getitem__
    return self._find_no_duplicates(name)
  File "/home/tendean/virtualenv/repositories/animemoeus/3.7/lib/python3.7/site-packages/requests/cookies.py", line 399, in _find_no_duplicates
    raise KeyError('name=%r, domain=%r, path=%r' % (name, domain, path))
KeyError: "name='csrftoken', domain=None, path=None"
>>> 

It's working on my computer, but not working on the server.

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.