从instagram帖子python获取点赞

问题描述 投票:1回答:1

我想从instagram帖子中抓取数据。我可以获得照片链接,喜欢计数和评论计数,但无法获得喜欢别人的帖子和评论的人的用户名。我使用pyInstaParser。有什么办法吗?

python web-scraping instagram instagram-api
1个回答
0
投票
import requests, sys, time from random import choice if len(sys.argv) < 2:sys.exit(f"Usage: {sys.argv[0]} <Post Link> <Proxy List>") Comments = 0 ProxList = [] Prox = open(sys.argv[2], "r")readlines() for line in ReadProx: ProxList.append(line.strip('\n')) while True: try: g = requests.get(sys.argv[1], proxies={'https://': 'https://'+choice(ProxList)}) print(g.json()) time.sleep(5) if len(g.json()['data']['shortcode_media']['edge_liked_by']['count']) > Comments: print(f"[+] Like | {g.json()['data']['shortcode_media']['edge_liked_by']['edges'][int(Comments)]['node']['username']}") if len(g.json()['data']['shortcode_media']['edge_liked_by']['count']) == Comments - 1: pass else: Comments += 1 time.sleep(1.5) except KeyboardInterrupt: sys.exit("Done") except Exception as e: print(e)
© www.soinside.com 2019 - 2024. All rights reserved.