【问题标题】:Get likes from post instagram python从 post instagram python 中获得喜欢
【发布时间】:2019-03-21 20:07:35
【问题描述】:

我想从 Instagram 帖子中抓取数据。我可以获得照片链接、点赞数和 cmets 数,但我无法从人们那里获得喜欢帖子和 cmets 的人的用户名。我使用 pyInstaParser。有没有办法做到这一点?

【问题讨论】:

标签: python web-scraping instagram instagram-api


【解决方案1】:

我不久前做了这个,但这应该适用于你正在尝试做的事情(使用 https 代理来防止 Instagram 限制请求)


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)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-04-03
    • 1970-01-01
    • 2012-09-03
    • 1970-01-01
    • 2012-07-15
    相关资源
    最近更新 更多