Hi Guys,
Please find a short guide of how to find out which Likes has been Organic and which came from boosting the post together with necessary files [will be send to you upon request, I can’t upload them in zipped format] to make it work.
Step 1. Install Python on your computer and make sure it’s working correctly.
Step 2. DM me for files [I will email them to you] or use this link: https://drive.google.com/folderview?id=1eBDuhzVbpe3h4HP_AKfjOpHt4O1lU_WA
Step 3. Unzipped the files and save them in one folder [It should look like this]
Step 4. On Windows, place your mouse cursor inside the folder with the files and press Ctrl + Shift + Right Mouse Button and open Windows PowerShell. It should look like this:
Step 5. type "python app.py +link to the account that you would like to check, press Enter
You should get something like this:
Step 6. Open result.txt from the Instagram Scraper folder. It should be populated with a data already
Step 7. Go to https://jsonlint.com/ and copy/paste the data from the result.txt. Press Validate JSON
Step 8. You should be able to see Total Likes and Organic Likes
The below part is for those who are interested where is this data actually coming from and how we know what’s what in Python.
-
There is much more information possible to extract, but I kept only what we were interested in. We used this guide kindly shared by @ido https://edmundmartin.com/scraping-instagram-with-python/
-
After testing it with one account, I think that value responsible for Organic Likes is “edge_liked_by” and “edge_media_preview_like” must be number of Total Likes including Sponsored.
-
Code below:
from random import choice
import json
import requests
from bs4 import BeautifulSoup
_user_agents = [
‘Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.181 Safari/537.36’
]
class InstagramScraper:
def __init__(self, user_agents=None, proxy=None):
self.user_agents = user_agents
self.proxy = proxy
def __random_agent(self):
if self.user_agents and isinstance(self.user_agents, list):
return choice(self.user_agents)
return choice(_user_agents)
def __request_url(self, url):
try:
response = requests.get(url, headers={'User-Agent': self.__random_agent()}, proxies={'http': self.proxy,
'https': self.proxy})
response.raise_for_status()
except requests.HTTPError:
raise requests.HTTPError('Received non 200 status code from Instagram')
except requests.RequestException:
raise requests.RequestException
else:
return response.text
@staticmethod
def extract_json_data(html):
soup = BeautifulSoup(html, 'html.parser')
body = soup.find('body')
script_tag = body.find('script')
raw_string = script_tag.text.strip().replace('window._sharedData =', '').replace(';', '')
return json.loads(raw_string)
def profile_page_metrics(self, profile_url):
results = {}
try:
response = self.__request_url(profile_url)
json_data = self.extract_json_data(response)
metrics = json_data['entry_data']['ProfilePage'][0]['graphql']['user']
except Exception as e:
raise e
else:
for key, value in metrics.items():
if key != 'edge_owner_to_timeline_media':
if value and isinstance(value, dict):
value = value['count']
results[key] = value
elif value:
results[key] = value
return results
def profile_page_recent_posts(self, profile_url):
results = []
try:
response = self.__request_url(profile_url)
json_data = self.extract_json_data(response)
metrics = json_data
#return metrics
metrics = json_data['entry_data']['ProfilePage'][0]['graphql']['user']['edge_owner_to_timeline_media']["edges"]
except Exception as e:
raise e
else:
for node in metrics:
node = node.get('node')
obj = dict()
obj['organic_likes'] = node['edge_liked_by']
obj['total_likes'] = node['edge_media_preview_like']
obj['url'] = node['display_url']
if node and isinstance(node, dict):
results.append(obj)
return results
Ps. Please let me know if you have more experience in this or spot a mistake so I can fix it.
Ps2. Is it possible to upload zipped files and attach them to this post so everyone can download them directly?
A big credit goes to @ido for pointing me in the right direction
Thanks