Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
710 B
3
Indexable
Never
import random
import requests

search_url = 'https://www.instagram.com/api/v1/web/search/topsearch/'

def search(keyword):
    rank_token = random.random()
    try:
        res = requests.get(search_url, params={
            'context': 'blended',
            'include_reel': 'true',
            'query': keyword,
            'rank_token': rank_token,
            'search_surface': 'web_top_search'
        })
        if res.status_code == 200:
            data = res.json()
            print("# users: ", len(data['users']))
            print(data['users'][0]['user'])
            print(data['users'][0]['user'].keys())
    except Exception as err:
        print(err)

search("vitaminC")