diff --git a/Scripts/Miscellaneous/Instagram_Analyzer/README.md b/Scripts/Miscellaneous/Instagram_Analyzer/README.md new file mode 100644 index 000000000..29e5eed96 --- /dev/null +++ b/Scripts/Miscellaneous/Instagram_Analyzer/README.md @@ -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/)diff%20--git%20a/Scripts/Miscellaneous/Instagram_Analyzer/instagram_analyzer.py%20b/Scripts/Miscellaneous/Instagram_Analyzer/instagram_analyzer.pynew%20file%20mode%20100644index%20000000000..17f6d4ca5---%20/dev/null+++%20b/Scripts/Miscellaneous/Instagram_Analyzer/instagram_analyzer.py@@%20-0,0%20+1,64%20@@+import%20matplotlib.pyplot%20as%20plt+import%20numpy%20as%20np+from%20instagramy%20import%20InstagramUser+import%20sys+++try:+%20%20%20%20filename%20=%20sys.argv[1]+%20%20%20%20print("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() diff --git a/Scripts/Miscellaneous/Instagram_Analyzer/requirements.txt b/Scripts/Miscellaneous/Instagram_Analyzer/requirements.txt new file mode 100644 index 000000000..d69cd6240 --- /dev/null +++ b/Scripts/Miscellaneous/Instagram_Analyzer/requirements.txt @@ -0,0 +1,3 @@ +instagramy==3.0 +matplotlib==3.3.2 +numpy==1.19.2 diff --git a/Scripts/Miscellaneous/Instagram_Analyzer/sample.png b/Scripts/Miscellaneous/Instagram_Analyzer/sample.png new file mode 100755 index 000000000..154023434 Binary files /dev/null and b/Scripts/Miscellaneous/Instagram_Analyzer/sample.png differ