Skip to main content

Get Instagram user and hashtag information and posts details without any third-party libraries

Project description

Instagramy

Python Package for Instagram Without Any external dependencies

PyPi Downloads GitHub stars GitHub forks GitHub license Code style GitHub Repo size Actions Actions

Scrape Instagram Users Information, Posts Details, and Hashtags details. This Package scrapes the user's recent posts with some information like likes, comments, captions and etc. No external dependencies.

Features

Download

Installation

pip install instagramy

Upgrade

pip install instagramy --upgrade

Sample Usage

Getting Session Id of Instrgram

For Login into Instagram via instagramy session id is required. No username or password is Needed. You must be login in same machine to get session id

  1. Login into Instagram in default webbrowser
  2. Move to Developer option
  3. Copy the sessionid
    • Move to storage and then to cookies and copy the sessionid (Firefox)
    • Move to Application and then to storage and then to cookies and copy the sessionid (Chrome)

Note: Don't use your session id from other machine's browser. It must be in current local machine.

Instagram User details

Class InstagramUser scrape some of the information related to the user of the Instagram

>>> from instagramy import InstagramUser

>>> session_id = "38566737751%3Ah7JpgePGAoLxJe%334"

>>> user = InstagramUser('google', sessionid=session_id)

>>> user.is_verified
True

>>> user.biography
'Google unfiltered—sometimes with filters.'

>>> user.user_data # More data about user as dict

Instagram Hashtag details

Class InstagramHashTag scrape some of the information related to the hash-tag of the Instagram

you can set your sessionid as env variable

$ export SESSION_ID="38566737751%3Ah7JpgePGAoLxJe%er40q"
>>> import os

>>> from instagramy import InstagramHashTag

>>> session_id = os.environ.get("SESSION_ID")

>>> tag = InstagramHashtag('google', sessionid=session_id)

>>> tag.number_of_posts
9556876

>>> tag.tag_data # More data about hashtag as dict

Instagram Post details

Class InstagramPost scrape some of the information related to the particular post of Instagram. It takes the post id as the parameter. You can get the post id from the URL of the Instagram posts from the property of InstagramUser.posts. or InstagramHagTag.top_posts

>>> from instagramy import InstagramPost

>>> session_id = "38566737751%3Ah7JpgePGAoLxJe%334"

>>> post = InstagramPost('CLGkNCoJkcM', sessionid=session_id)

>>> post.author
'ipadpograffiti'

>>> post.number_of_likes
1439

>>> post.post_data # More data about post as dict

Plugins

Instagramy has some plugins for ease

Plugins for Data Analyzing

  • analyze_users_popularity
  • analyze_hashtags
  • analyze_user_recent_posts
>>> import pandas as pd
>>> from instagramy.plugins.analysis import analyze_users_popularity

>>> session_id = "38566737751%3Ah7JpgePGAoLxJe%334"

>>> teams = ["chennaiipl", "mumbaiindians", 
        "royalchallengersbangalore", "kkriders", 
        "delhicapitals", "sunrisershyd",  
        "kxipofficial"]
>>> data = analyze_users_popularity(teams, session_id)
>>> pd.Dataframe(data)

                   Usernames  Followers  Following  Posts
0                 chennaiipl    6189292        194   5646
1              mumbaiindians    6244961        124  12117
2  royalchallengersbangalore    5430018         59   8252
3                   kkriders    2204739         68   7991
4              delhicapitals    2097515         75   9522
5               sunrisershyd    2053824         70   6227
6               kxipofficial    1884241         67   7496

Plugins for Downloading Posts

  • download_hashtags_posts
  • download_post
  • download_profile_pic
>>> import os

>>> from instagramy.plugins.download import *

>>> session_id = os.environ.get('SESSION_ID')

>>> download_profile_pic(username='google', sessionid=session_id, filepath='google.png')

>>> download_post(id="ipadpograffiti", sessionid=session_id, filepath='post.mp4')

>>> download_hashtags_posts(tag="tamil", session_id=session_id, count=2)

Use Without Login

You can use this package without login. Sessionid is not required but it may rise error after four to five requests.

>>> from instagramy import *

>>> user = InstagramUser('google')
>>> user.fullname
'Google'
>>> tag = InstagramHashTag('python')
>>> tag.tag_data

✏️ Important Notes

  • You can use this package without sessionid (Login). But it may RedirectionError after four to five requests.
  • class Viewer provide the data about currently logged in user
  • Don't provide wrong session_id
  • InstagramUser.user_data, InstagramPost.post_data and InstagramHashtag.tag_data which is python dict has more and more data other than defined as Properties
  • This Package does not work in Remote PC or any Online python Interpreter.
  • This Package does not scrap all the posts from an account, the limit of the post only 12 (For non-private account)
  • This Package not scrap all the posts of given hash-tag it only scrapes the top 60 - 70 posts.

Made with Python ❤️

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

instagramy-4.2.tar.gz (13.0 kB view hashes)

Uploaded Source

Built Distribution

instagramy-4.2-py3-none-any.whl (15.2 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page