2024抖音直播间采集|采集礼物进入发言弹幕内容|让你流量翻倍|抖音直播评论采集|好用推荐

import requests
import json
import time

class DouyinLiveCommentCrawler:
    def __init__(self, live_id, access_token):
        self.live_id = live_id
        self.access_token = access_token
        self.url = "https://api.douyin.com/aweme/v1/live/comments/"
        self.params = {
            "live_id": live_id,
            "cursor": "0",
            "count": "20"
        }
        self.headers = {
            "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.3",
            "Authorization": "Bearer " + access_token
        }

    def crawl_comments(self):
        while True:
            try:
                response = requests.get(self.url, params=self.params, headers=self.headers, timeout=10)
                response.raise_for_status()
            except requests.exceptions.RequestException as e:
                print("请求错误:", e)
                time.sleep(5)
                continue

            data = json.loads(response.text)

            if data["status_code"] != 0:
                print("错误代码:", data["status_code"], "错误信息:", data["status_msg"])
                break

            for comment in data["comments"]:
                print("评论用户:", comment["user"]["nickname"])
                print("评论内容:", comment["text"])
                print("评论时间:", comment["create_time"])
                print("------------")

            if data["has_more"] == 0:
                break

            self.params["cursor"] = data["cursor"]
            time.sleep(1)  # 速率限制,0.1秒爬取一次

if __name__ == "__main__":
    live_id = "your_live_id"
    access_token = "your_access_token"
    crawler = DouyinLiveCommentCrawler(live_id, access_token)
    crawler.crawl_comments()

抖音直播间工具箱

功能1:支持批量导入直播间链接采集 支持关键词搜索直播间进行采集(可过滤匿名)
功能2:访客进入直播间 动作 礼物 发言 昵称 等级 性别 地区 粉丝 等显示 
功能3自动去重 单击可显示二维码主页 作品链接 粉丝 关注等
功能5:可进行多条件筛选匹配 显示精准 过滤无作品 私密账号 过滤性别等 匹配指定多地区  匹配多评论关键词
功能6:支持自动智能导出 支持继续过滤

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值