Skip to content
This repository was archived by the owner on Dec 22, 2023. It is now read-only.

Added Instagram Analyzer #105

Merged
merged 6 commits into from
Oct 1, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions Scripts/Miscellaneous/Instagram_Analyzer/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Instagram Analyzer

This Scripts analyze the Instagram user data like Followers, Followings and Posts with Matplotlib
bar charts.

## Prerequisites

Install the required packages

`pip install -r requirements.txt`

## How to use this script?

1.Make a text file of list of Instagram username. For example
`user.txt` contains

```
github
pubg
facebook
iplt20
chennaiipl
google
```

2.Run the script

```python instagram_analyzer.py user.txt```

## Screenshot
![screenshot](sample.png)
## Author

[YOGESHWARAN R]("https://github.com/yogeshwaran01/)
64 changes: 64 additions & 0 deletions Scripts/Miscellaneous/Instagram_Analyzer/instagram_analyzer.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
import matplotlib.pyplot as plt
import numpy as np
from instagramy import InstagramUser
import sys


try:
filename = sys.argv[1]
print("Extracting...")
except (IndexError, KeyError):
print("List of username as textfile in argvment")
sys.exit()

usernames = []
file = open(filename, "r")
for line in file:
if line != "\n":
usernames.append(str(line).strip())
followers = []
following = []
posts = []

for username in usernames:
user = InstagramUser(username)
followers.append(user.number_of_followers)
following.append(user.number_of_followings)
posts.append(user.number_of_posts)

x = np.arange(len(usernames)) # the label locations
width = 0.25 # the width of the bars

fig, ax = plt.subplots()
rects1 = ax.bar(x + 0.2, followers, width, label="Followers")
rects2 = ax.bar(x, following, width, label="Following")
rects3 = ax.bar(x - 0.2, posts, width, label="Posts")

# Add some text for labels, title and custom x-axis tick labels, etc.
ax.set_ylabel("Popularity")
ax.yaxis.set_visible(True)
ax.set_title("Username")
ax.set_xticks(x)
ax.set_xticklabels(usernames)
ax.legend()


def autolabel(rects):
"""Attach a text label above each bar in *rects*, displaying its height."""
for rect in rects:
height = rect.get_height()
ax.annotate(
"{}".format(height),
xy=(rect.get_x() + rect.get_width() / 2, height),
xytext=(0, 3), # 3 points vertical offset
textcoords="offset points",
ha="center",
va="bottom",
)


autolabel(rects1)
autolabel(rects2)
autolabel(rects3)
fig.tight_layout()
plt.show()
3 changes: 3 additions & 0 deletions Scripts/Miscellaneous/Instagram_Analyzer/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
instagramy==3.0
matplotlib==3.3.2
numpy==1.19.2
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.