Thursday, January 5, 2023

scrap

import requests import json # Set the username of the account you want to scrape username = "instagram" # Set the URL for the Instagram API endpoint for the account url = f"https://www.instagram.com/{username}/?__a=1" # Send a GET request to the API endpoint response = requests.get(url) # Get the data from the response as a JSON object data = response.json() # Extract the relevant data from the JSON object username = data["graphql"]["user"]["username"] full_name = data["graphql"]["user"]["full_name"] followers = data["graphql"]["user"]["edge_followed_by"]["count"] posts = data["graphql"]["user"]["edge_owner_to_timeline_media"]["count"] # Print the data print(f"Username: {username}") print(f"Full name: {full_name}") print(f"Followers: {followers}") print(f"Posts: {posts}")

No comments:

Post a Comment

scrap

import requests import json # Set the username of the account you want to scrape username = "instagram" # Set the URL for the In...