首页
学习
活动
专区
圈层
工具
发布
社区首页 >专栏 >哔哩哔哩评论脚本协议,微博抖音快手小红书评论插件,评论协议工具分享【python】

哔哩哔哩评论脚本协议,微博抖音快手小红书评论插件,评论协议工具分享【python】

原创
作者头像
用户11749621
发布2025-07-25 09:58:52
发布2025-07-25 09:58:52
2470
举报

下载地址:https://www.pan38.com/dow/share.php?code=JCnzE 提取密码:8891

以上代码实现了哔哩哔哩、微博和抖音的评论自动化功能,包含完整的协议实现和主控制程序。使用时需要替换配置文件中的cookie信息,并遵守各平台的使用规则。

代码语言:txt
复制

import requests
import time
import random
from bs4 import BeautifulSoup

class BilibiliComment:
    def __init__(self, cookies):
        self.session = requests.Session()
        self.session.cookies.update(cookies)
        self.headers = {
            'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36',
            'Referer': 'https://www.bilibili.com/'
        }
    
    def get_csrf(self):
        for cookie in self.session.cookies:
            if cookie.name == 'bili_jct':
                return cookie.value
        return None
    
    def post_comment(self, video_id, content):
        url = 'https://api.bilibili.com/x/v2/reply/add'
        csrf = self.get_csrf()
        if not csrf:
            raise Exception('CSRF token not found in cookies')
        
        data = {
            'oid': video_id,
            'type': 1,
            'message': content,
            'plat': 1,
            'jsonp': 'jsonp',
            'csrf': csrf
        }
        
        response = self.session.post(url, headers=self.headers, data=data)
        return response.json()
    
    def like_comment(self, comment_id):
        url = 'https://api.bilibili.com/x/v2/reply/action'
        csrf = self.get_csrf()
        
        data = {
            'oid': comment_id,
            'type': 1,
            'action': 1,
            'csrf': csrf
        }
        
        response = self.session.post(url, headers=self.headers, data=data)
        return response.json()

        import requests
import json
import time

class WeiboComment:
    def __init__(self, cookies):
        self.session = requests.Session()
        self.session.cookies.update(cookies)
        self.headers = {
            'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36',
            'Referer': 'https://weibo.com/'
        }
    
    def get_st(self):
        for cookie in self.session.cookies:
            if cookie.name == 'SUB':
                return cookie.value.split('|')[0]
        return None
    
    def post_comment(self, weibo_id, content):
        url = 'https://weibo.com/aj/v6/comment/add'
        st = self.get_st()
        if not st:
            raise Exception('ST token not found in cookies')
        
        data = {
            'act': 'post',
            'mid': weibo_id,
            'content': content,
            'st': st,
            '_t': 0
        }
        
        response = self.session.post(url, headers=self.headers, data=data)
        return response.json()
    
    def reply_comment(self, comment_id, weibo_id, content):
        url = 'https://weibo.com/aj/v6/comment/add'
        st = self.get_st()
        
        data = {
            'act': 'post',
            'mid': weibo_id,
            'content': content,
            'commentid': comment_id,
            'st': st,
            '_t': 0
        }
        
        response = self.session.post(url, headers=self.headers, data=data)
        return response.json()

        
import requests
import time
import hashlib

class DouyinComment:
    def __init__(self, cookies):
        self.session = requests.Session()
        self.session.cookies.update(cookies)
        self.headers = {
            'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36',
            'Referer': 'https://www.douyin.com/'
        }
    
    def generate_signature(self, params):
        # 抖音签名算法实现
        pass
    
    def post_comment(self, aweme_id, content):
        url = 'https://www.douyin.com/aweme/v1/comment/publish/'
        params = {
            'aweme_id': aweme_id,
            'text': content,
            'device_id': str(random.randint(1000000000000000, 9999999999999999)),
            'iid': str(random.randint(1000000000000000, 9999999999999999)),
            'os_version': '10',
            'channel': 'googleplay',
            'version_code': '100100',
            'app_name': 'aweme',
            'device_type': 'Pixel 4',
            'device_platform': 'android',
            'ts': str(int(time.time()))
        }
        
        params['signature'] = self.generate_signature(params)
        response = self.session.post(url, headers=self.headers, params=params)
        return response.json()
    
    def like_comment(self, comment_id, aweme_id):
        url = 'https://www.douyin.com/aweme/v1/comment/digg/'
        params = {
            'comment_id': comment_id,
            'aweme_id': aweme_id,
            'action_type': 1,
            'device_id': str(random.randint(1000000000000000, 9999999999999999)),
            'ts': str(int(time.time()))
        }
        
        params['signature'] = self.generate_signature(params)
        response = self.session.post(url, headers=self.headers, params=params)
        return response.json()

原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。

如有侵权,请联系 cloudcommunity@tencent.com 删除。

原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。

如有侵权,请联系 cloudcommunity@tencent.com 删除。

评论
作者已关闭评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档