CoderFromHell
Power Member
- Mar 19, 2019
- 727
- 341
Python:
from bs4 import BeautifulSoup
import requests
r = requests.get('https://www.instagram.com/worldstar/?hl=en')
#Link of the Instagram Profile that I would like to Scrape Data from
def parse_data(s):
# creating a dictionary
data = {}
# splittting the content
# then taking the first part
s = s.split("-")[0]
# again splitting the content
s = s.split(" ")
# assigning the values
data['Post'] = s[4]
# returning the dictionary
PostAmount = data['Post']
return PostAmount
soup = BeautifulSoup(r.text, 'lxml')
meta = soup.find('meta', property="og:description")
#found this from the html source of any instagram profile source code
print (parse_data(meta.attrs['content']))
#prints the description of an instagram profile; their followers,
#following amount and post amount
This code above works only on pages with 9,999 Amount of Post and below. Pages with more than 10,000 Post return 10.1k or 27.k. Im trying to aquire the exact amount of post from an Instagram Profile. Is their another way I can do that?