Created
March 31, 2020 04:59
-
-
Save seunggabi/a4fde805d7360e91272758718e55629a to your computer and use it in GitHub Desktop.
instagram_follower.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
from bs4 import BeautifulSoup | |
import json | |
import sys | |
from datetime import datetime | |
# window._sharedData.entry_data.ProfilePage[0].graphql.user.edge_followed_by.count | |
try: | |
id = sys.argv[1] | |
except IndexError: | |
id = "seunggabi.kim" | |
url = "https://www.instagram.com/"+id+"/" | |
source_code = requests.get(url) | |
source_code.encoding = "utf-8" | |
contents = source_code.text | |
soup = BeautifulSoup(contents, "html.parser") | |
# mainEntityofPage.interactionStatistic.userInteractionCount | |
target = soup.find("script", {"type": "application/ld+json"}) | |
info = json.loads(target.text) | |
count = info['mainEntityofPage']['interactionStatistic']['userInteractionCount']; | |
print(datetime.now().isoformat()+" "+count) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment