Skip to content
This repository was archived by the owner on Nov 30, 2022. It is now read-only.

Instagram scraper #255

Merged
merged 3 commits into from
Sep 12, 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
7 changes: 7 additions & 0 deletions Web-Scraping/Instagram/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# INSTAGRAM SCRAPPER

### Instagram_count

- This Script counts the number of followings, followers and posts.
- Takes the username from the terminal and shows them the output.

31 changes: 31 additions & 0 deletions Web-Scraping/Instagram/instagram_count.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
from bs4 import BeautifulSoup
import requests

#The instagram URL
URL="https://www.instagram.com/{}/"
username = input(" Enter the instagram username ")

#request a response from the URL
response = requests.get(URL.format(username))
# scraping the contents
soup = BeautifulSoup(response.text,"html.parser")
#The contents of the meta tag with the property og:description are accessed here
meta_content = soup.find("meta", property="og:description")
#print(meta_content)
data = {}
content = meta_content.attrs['content']
content = content.split("-")[0]
content = content.split(" ")

data['Followers'] = content[0]
data['Following'] = content[2]
data['Posts'] = content[4]

print(username + " has " + data["Followers"]+" followers, "+ data["Following"]+" following, "+ data["Posts"]+" posts ")


'''
output:
Enter the instagram username "ferrari"
ferrari has 19m followers, 5 following, 2,538 posts
'''