Giter Site home page Giter Site logo

labteral / pygram Goto Github PK

View Code? Open in Web Editor NEW
43.0 3.0 5.0 56 KB

Unofficial Python client for Instagram

License: GNU General Public License v3.0

Shell 0.87% Python 99.13%
instagram bot sdk instagram-api instagram-client instagram-sdk instagram-bot instagram-scraper instagram-photos instagram-feed instagram-downloader instagram-crawler instagram-download

pygram's Introduction

Pygram Logo

Downloads PyPi License

Unofficial Python client for Instagram

Buy Me A Coffee

Installation

pip install pygram

Methods without mandatory login

Get user's profile

from pygram import PyGram
pygram = PyGram()

profile = pygram.get_profile('eminem')

Get user's ID

from pygram import PyGram
pygram = PyGram()

user_id = pygram.get_user_id('eminem')

Get user's posts

from pygram import PyGram
pygram = PyGram()

posts = pygram.get_posts('eminem', limit=10)
for post in posts:
    print(post)

Get post's comments

from pygram import PyGram
pygram = PyGram()

comments = pygram.get_comments(post, limit=10)
for comment in comments:
    print(comment)

Methods with mandatory login

Login

from pygram import PyGram

pygram = PyGram('user', 'password')

After the first login, a file with the name pygram-cache.json will be created in the current directory to avoid logging in again with every instantiation.

Get user's followers

from pygram import PyGram
pygram = PyGram('user', 'password')

users = pygram.get_followers('eminem', limit=10)
for user in users:
    print(user)

Get users followed by a user

from pygram import PyGram
pygram = PyGram('user', 'password')

users = pygram.get_followed('drdre', limit=10)
for user in users:
    print(user)

Like a post / comment

from pygram import PyGram
pygram = PyGram('user', 'password')

last_post = next(pygram.get_posts('eminem', limit=1))
pygram.like(last_post)

Unlike a post / comment

from pygram import PyGram
pygram = PyGram('user', 'password')

last_post = next(pygram.get_posts('eminem', limit=1))
pygram.unlike(last_post)

Comment a post / comment

from pygram import PyGram
pygram = PyGram('user', 'password')

pygram.comment(post, 'this is the comment')

Delete a comment

from pygram import PyGram
pygram = PyGram('user', 'password')

pygram.delete(comment)

pygram's People

Contributors

brunneis 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

Watchers

 avatar  avatar  avatar

pygram's Issues

ERROR: No matching distribution found for pygram

my os: arch linux 64 bit
the command i ran: pip3 install pygram

result:

Defaulting to user installation because normal site-packages is not writeable
Collecting pygram
  Downloading pygram-0.0.13b0-py3-none-any.whl (17 kB)
WARNING: Discarding https://files.pythonhosted.org/packages/03/ba/30bdbbc96999e3217a23046474a2485fdac606e13cb79efa7ecadec4dd31/pygram-0.0.13b0-py3-none-any.whl#sha256=59be3f5bb24c853e2e23fad4b71780f0723797d980e18ef24b0dbe9df53769d6 (from https://pypi.org/simple/pygram/) (requires-python:>=3.6). Requested pygram from https://files.pythonhosted.org/packages/03/ba/30bdbbc96999e3217a23046474a2485fdac606e13cb79efa7ecadec4dd31/pygram-0.0.13b0-py3-none-any.whl#sha256=59be3f5bb24c853e2e23fad4b71780f0723797d980e18ef24b0dbe9df53769d6 has inconsistent version: filename has '0.0.13b0', but metadata has '0.0.13b0'
  Downloading pygram-0.0.12b0-py3-none-any.whl (17 kB)
WARNING: Discarding https://files.pythonhosted.org/packages/65/75/0dd5fe9ce38018a6d2741f281ee9659f5a38649a2c5d6ff79073d1a9706c/pygram-0.0.12b0-py3-none-any.whl#sha256=58aba9b41ec1268da2ea89acce42b225dbf5bfe22ec8d0fafd7dd27ca09bafd8 (from https://pypi.org/simple/pygram/) (requires-python:>=3.6). Requested pygram from https://files.pythonhosted.org/packages/65/75/0dd5fe9ce38018a6d2741f281ee9659f5a38649a2c5d6ff79073d1a9706c/pygram-0.0.12b0-py3-none-any.whl#sha256=58aba9b41ec1268da2ea89acce42b225dbf5bfe22ec8d0fafd7dd27ca09bafd8 has inconsistent version: filename has '0.0.12b0', but metadata has '0.0.12b0'
  Downloading pygram-0.0.11b0-py3-none-any.whl (17 kB)
WARNING: Discarding https://files.pythonhosted.org/packages/fe/b5/15e42bfb8e64c90d9d733fd7a7658f27a926124c6760e4973cc57f820703/pygram-0.0.11b0-py3-none-any.whl#sha256=3dc1772187779e4124a84e881e820ae4ba90b0e9fc2b776ae243c8d057b82f1c (from https://pypi.org/simple/pygram/) (requires-python:>=3.6). Requested pygram from https://files.pythonhosted.org/packages/fe/b5/15e42bfb8e64c90d9d733fd7a7658f27a926124c6760e4973cc57f820703/pygram-0.0.11b0-py3-none-any.whl#sha256=3dc1772187779e4124a84e881e820ae4ba90b0e9fc2b776ae243c8d057b82f1c has inconsistent version: filename has '0.0.11b0', but metadata has '0.0.11b0'
  Downloading pygram-0.0.10b0-py3-none-any.whl (17 kB)
WARNING: Discarding https://files.pythonhosted.org/packages/d5/71/6c25d287ede54dc9f952e64168bc73e8e68a8a4ffc1b18e06f71bff4d6d9/pygram-0.0.10b0-py3-none-any.whl#sha256=ee1cffc9d7c6c95851ffc1a44736f35df1d55e872c57606ac363dc603f4adb1e (from https://pypi.org/simple/pygram/) (requires-python:>=3.6). Requested pygram from https://files.pythonhosted.org/packages/d5/71/6c25d287ede54dc9f952e64168bc73e8e68a8a4ffc1b18e06f71bff4d6d9/pygram-0.0.10b0-py3-none-any.whl#sha256=ee1cffc9d7c6c95851ffc1a44736f35df1d55e872c57606ac363dc603f4adb1e has inconsistent version: filename has '0.0.10b0', but metadata has '0.0.10b0'
  Downloading pygram-0.0.9b0-py3-none-any.whl (17 kB)
WARNING: Discarding https://files.pythonhosted.org/packages/3b/ef/e4319dff0a87e30b994344510275ab44bf34eb62785e34b58f11bde18dfb/pygram-0.0.9b0-py3-none-any.whl#sha256=108864ad4bd58c16c75fc0497d7d31408440d2386424b4f07a507c5bc0ef3a35 (from https://pypi.org/simple/pygram/) (requires-python:>=3.6). Requested pygram from https://files.pythonhosted.org/packages/3b/ef/e4319dff0a87e30b994344510275ab44bf34eb62785e34b58f11bde18dfb/pygram-0.0.9b0-py3-none-any.whl#sha256=108864ad4bd58c16c75fc0497d7d31408440d2386424b4f07a507c5bc0ef3a35 has inconsistent version: filename has '0.0.9b0', but metadata has '0.0.9b0'
  Downloading pygram-0.0.8b0-py3-none-any.whl (17 kB)
WARNING: Discarding https://files.pythonhosted.org/packages/c9/b5/39b16a2521aeee9f34ef64bb378adddf038c2cdf734547c4508869159bfa/pygram-0.0.8b0-py3-none-any.whl#sha256=ecad50c982b3986ef64d45b6223f056251b3d16da5258ecc8fa24031bee87384 (from https://pypi.org/simple/pygram/) (requires-python:>=3.6). Requested pygram from https://files.pythonhosted.org/packages/c9/b5/39b16a2521aeee9f34ef64bb378adddf038c2cdf734547c4508869159bfa/pygram-0.0.8b0-py3-none-any.whl#sha256=ecad50c982b3986ef64d45b6223f056251b3d16da5258ecc8fa24031bee87384 has inconsistent version: filename has '0.0.8b0', but metadata has '0.0.8b0'
  Downloading pygram-0.0.7b0-py3-none-any.whl (17 kB)
WARNING: Discarding https://files.pythonhosted.org/packages/11/11/d2bf8f671862cc3c0cbe476faa4f6135dcbeeed1829b2b03df425ad76d84/pygram-0.0.7b0-py3-none-any.whl#sha256=2712bf2b07ab2657983b50e97f518941ff83098d64088ce51b3fd76d101225d4 (from https://pypi.org/simple/pygram/) (requires-python:>=3.6). Requested pygram from https://files.pythonhosted.org/packages/11/11/d2bf8f671862cc3c0cbe476faa4f6135dcbeeed1829b2b03df425ad76d84/pygram-0.0.7b0-py3-none-any.whl#sha256=2712bf2b07ab2657983b50e97f518941ff83098d64088ce51b3fd76d101225d4 has inconsistent version: filename has '0.0.7b0', but metadata has '0.0.7b0'
  Downloading pygram-0.0.6b0-py3-none-any.whl (17 kB)
WARNING: Discarding https://files.pythonhosted.org/packages/8f/33/ccc237164d255ca43647778060613c41fb4663cb4477cdd9dba86fe9b5cc/pygram-0.0.6b0-py3-none-any.whl#sha256=6f403f17edce64841335f503f2788978c53e0965048cedd06453125dc35d96bc (from https://pypi.org/simple/pygram/) (requires-python:>=3.6). Requested pygram from https://files.pythonhosted.org/packages/8f/33/ccc237164d255ca43647778060613c41fb4663cb4477cdd9dba86fe9b5cc/pygram-0.0.6b0-py3-none-any.whl#sha256=6f403f17edce64841335f503f2788978c53e0965048cedd06453125dc35d96bc has inconsistent version: filename has '0.0.6b0', but metadata has '0.0.6b0'
  Downloading pygram-0.0.5b0-py3-none-any.whl (17 kB)
WARNING: Discarding https://files.pythonhosted.org/packages/07/6c/4756572db5c32aee987fc156213117f2531147ab09f0b98ced7b0003cb1b/pygram-0.0.5b0-py3-none-any.whl#sha256=c2b6b2ae08b9b719c36e7b21d04c11c7f645e68ff4722cbcb3675f04469bc2e7 (from https://pypi.org/simple/pygram/) (requires-python:>=3.6). Requested pygram from https://files.pythonhosted.org/packages/07/6c/4756572db5c32aee987fc156213117f2531147ab09f0b98ced7b0003cb1b/pygram-0.0.5b0-py3-none-any.whl#sha256=c2b6b2ae08b9b719c36e7b21d04c11c7f645e68ff4722cbcb3675f04469bc2e7 has inconsistent version: filename has '0.0.5b0', but metadata has '0.0.5b0'
  Downloading pygram-0.0.4b0-py3-none-any.whl (17 kB)
WARNING: Discarding https://files.pythonhosted.org/packages/62/09/5ad84773772a61da0478e6d2193284467ce7cc0cc088e1a424c2c28415ac/pygram-0.0.4b0-py3-none-any.whl#sha256=694259cb0bf1f4d72c48db63838108db9cb7e5612b64a206cfd867d2c143152e (from https://pypi.org/simple/pygram/) (requires-python:>=3.6). Requested pygram from https://files.pythonhosted.org/packages/62/09/5ad84773772a61da0478e6d2193284467ce7cc0cc088e1a424c2c28415ac/pygram-0.0.4b0-py3-none-any.whl#sha256=694259cb0bf1f4d72c48db63838108db9cb7e5612b64a206cfd867d2c143152e has inconsistent version: filename has '0.0.4b0', but metadata has '0.0.4b0'
  Downloading pygram-0.0.3b0-py3-none-any.whl (17 kB)
WARNING: Discarding https://files.pythonhosted.org/packages/00/7c/efa2fd64ae703b399a1ab567c27b260b51cc50ed1696544b9f7f02a10724/pygram-0.0.3b0-py3-none-any.whl#sha256=8ee8afa642e39bd166bfce4d4f4fdaca662a153a095525044bd97c662a7474c2 (from https://pypi.org/simple/pygram/) (requires-python:>=3.6). Requested pygram from https://files.pythonhosted.org/packages/00/7c/efa2fd64ae703b399a1ab567c27b260b51cc50ed1696544b9f7f02a10724/pygram-0.0.3b0-py3-none-any.whl#sha256=8ee8afa642e39bd166bfce4d4f4fdaca662a153a095525044bd97c662a7474c2 has inconsistent version: filename has '0.0.3b0', but metadata has '0.0.3b0'
ERROR: Could not find a version that satisfies the requirement pygram
ERROR: No matching distribution found for pygram

anyone know why this happens?

pygram.get_comments ERROR

from pygram import PyGram
pygram = PyGram()

comments = pygram.get_comments(post, limit=10)
for comment in comments:
    print(comment)

image

JSONDecodeError and ActionError while running on AWS ubuntu instance.

I installed the package on my windows command prompt and the crawler worked perfectly.
I need to make it work on my AWS ubuntu instance but it throws a JSONDecodeError and ActionError.
I am running a AWS with Ubunutu release 18.04 LTS.
My commands on AWS instance were:

pip3 install pygram
python3
>>> from pygram import PyGram
>>> pygram = PyGram()
>>>profile = pygram.get_profile('eminem')

Screenshot of the AWS instance:
image

AuthenticationError when logging in with different Instagram Account

Summary

I believe there is some kind of bug in the logic or order of execution for the _login function having to do with the cached login headers. When trying to log in to a different Instagram Account using the PyGram(username, password) call, I get an AuthenticationError. In addition, when copying my script between two different machines, I received the same AuthenticationError unless I also copied over the pygram-cache.json file too. I have checked and verified that my internet connection was working at the time so it likely isn't throwing any Error 500 or 400 codes which would throw the AuthenticationError.

Steps to reproduce the AuthenticationError:

(Requires 2 Instagram Accounts (A & B))

  1. Sign in to Instagram Account A by calling pygram = PyGram(username, password) as described in the ReadMe.md.

  2. Verify the pygram-cache.json file has been generated successfully.

  3. Sign in to Instagram Account B by calling pygram = PyGram(username, password) as described in the ReadMe.md.

  4. It throws the AuthenticationError and the pygram-cache.json file hasn't changed or updated because it failed to authenticate.

Below is the traceback from the error I received:

Traceback (most recent call last): File ".\getInstafollowers.py", line 67, in <module> pygram = PyGram(instaUserName, instaPassword) File "C:\Users\erikb\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\pygram\pygram.py", line 30, in __init__ self._login() File "C:\Users\erikb\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\pygram\pygram.py", line 137, in _login raise AuthenticationError pygram.errors.AuthenticationError

Authentication Error issue while login()

Hey,

Once again, Sorry to bother you.

I am looking into login() method and it throws me authentication error every time I try to login.

This is the piece of code I have tried.

from pygram import Pygram
pygr = PyGram('onebyzero2506', 'demo1234')

I did some debugging myself and it seems like the request is failing with status code 400. Did something change from instagram side (or) am I making some rookie mistake? :)

JSONDecodeError

Clipboard01

i am not quite sure, what this error is meant to be. The JSON file
https://www.instagram.com/eminem/?__a=1
looks ok.

Is it probably a incompability of libs? I tried to reinstall several times and set up the exact enviromment, but know i am quite unsure if thats the missing link ... Any suggestions? @brunneis

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.