-
Notifications
You must be signed in to change notification settings - Fork 77
/
instagram.py
45 lines (26 loc) · 910 Bytes
/
instagram.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/usr/bin/env python
# coding: utf-8
# In[20]:
get_ipython().system('pip install beautifulsoup4')
# In[23]:
import requests
from bs4 import BeautifulSoup
def scrapInstagram(soup1):
insta_Data = []
for meta in soup1.find_all(name="meta",attrs={"property":"og:description"}):
insta_Data = meta['content'].split()
followers = insta_Data[0]
following = insta_Data[2]
posts = insta_Data[4]
print("\n INSTAGRAM USERNAME : ", insta_User)
print("\n No OF POSTS : ", posts)
print("\n No OF FOLLOWERS : ", followers)
print("\n No OF FOLLOWING : ", following)
# In[24]:
if __name__ == "__main__" :
insta_User = input("\n ENTER INSTAGRAM USERNAME : ")
insta_URL = "https://www.instagram.com/" + insta_User
insta_Page = requests.get(insta_URL)
soup = BeautifulSoup(insta_Page.text,"html.parser")
scrapInstagram(soup)
# In[ ]: