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

Commit fd240ee

Browse files
authored
Merge pull request #255 from rutujadhanawade/Instagram_scrap
Instagram scraper
2 parents 7089957 + 87ea768 commit fd240ee

File tree

2 files changed

+38
-0
lines changed

2 files changed

+38
-0
lines changed

Web-Scraping/Instagram/README.md

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# INSTAGRAM SCRAPPER
2+
3+
### Instagram_count
4+
5+
- This Script counts the number of followings, followers and posts.
6+
- Takes the username from the terminal and shows them the output.
7+
+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
from bs4 import BeautifulSoup
2+
import requests
3+
4+
#The instagram URL
5+
URL="https://www.instagram.com/{}/"
6+
username = input(" Enter the instagram username ")
7+
8+
#request a response from the URL
9+
response = requests.get(URL.format(username))
10+
# scraping the contents
11+
soup = BeautifulSoup(response.text,"html.parser")
12+
#The contents of the meta tag with the property og:description are accessed here
13+
meta_content = soup.find("meta", property="og:description")
14+
#print(meta_content)
15+
data = {}
16+
content = meta_content.attrs['content']
17+
content = content.split("-")[0]
18+
content = content.split(" ")
19+
20+
data['Followers'] = content[0]
21+
data['Following'] = content[2]
22+
data['Posts'] = content[4]
23+
24+
print(username + " has " + data["Followers"]+" followers, "+ data["Following"]+" following, "+ data["Posts"]+" posts ")
25+
26+
27+
'''
28+
output:
29+
Enter the instagram username "ferrari"
30+
ferrari has 19m followers, 5 following, 2,538 posts
31+
'''

0 commit comments

Comments
 (0)