天谪小红书群控系统测试版 自动生成图片自动发笔记,自动评论等功能。

空闲时间写的软件,目前正在开发中,算是写到一半了吧。发出来大家一起研究研究。

主要用途:小红书小号日常更新。

功能:自动生成图片、免接口通义生成笔记、小红书多账号管理、定时发布、审核后发布、按关键词搜索笔记后自动评论点赞收藏,自动同步小豆芽账号[可用于接任务]。

图片生成方式:自定义背景图或生成的信笺图片+自定义随机字体+随机排列=笔记图片
测试软件运行环境:win10 .net 4.7以上 Node.js 其它系统自行测试。

在这里插入图片描述
软件:小红书群控系统测试版 以下是展示图片:

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
图片生成器与小红书发送接口代码如下:

from flask import Flask, request, jsonify
import jieba
import json
import os
import execjs
import requests
import random
import time
from PIL import Image, ImageDraw, ImageFont, ImageStat
from datetime import datetime
import math
import string
import random
import base64

app = Flask(__name__)

headers = {
   
    "accept": "application/json, text/plain, */*",
    "accept-language": "zh-CN,zh;q=0.9",
    "cache-control": "no-cache",
    "content-type": "application/json;charset=UTF-8",
    "origin": "https://www.xiaohongshu.com",
    "pragma": "no-cache",
    "referer": "https://www.xiaohongshu.com/",
    "sec-ch-ua": "\"Chromium\";v=\"112\", \"Google Chrome\";v=\"112\", \"Not:A-Brand\";v=\"99\"",
    "sec-ch-ua-mobile": "?0",
    "sec-ch-ua-platform": "\"Windows\"",
    "sec-fetch-dest": "empty",
    "sec-fetch-mode": "cors",
    "sec-fetch-site": "same-site",
    "user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/112.0.0.0 Safari/537.36",
}

PUNCTUATION = ",。!?:;、()“”‘’【】[]《》〈〉…—~·!@#$%^&*()_+-=<>?/\\\"'`"

# 常见符号列表用于信笺四角装饰
DECORATIVE_SYMBOLS = ["circle", "star", "heart", "zigzag", "zigzags","sun", "moon", "wave", "dashed", "lightning"]

def get_random_font(font_directory='ttf'):
    """
    随机从指定目录中选择一个字体文件
    """
    # 获取 ttf 目录下的所有文件
    font_files = [f for f in os.listdir(font_directory) if f.endswith('.ttf')]

    # 如果目录中没有字体文件,抛出错误
    if not font_files:
        raise FileNotFoundError("在指定的字体目录中没有找到任何字体文件")

    # 随机选择一个字体文件
    random_font = random.choice(font_files)
    return os.path.join(font_directory, random_font)
    
    
def segment_text(text):
    words = jieba.lcut(text)
    lines = []
    current_line = ""

    # 定义随机让词语独占一行的概率
    single_word_prob = 0.05
    two_words_prob = 0.1
    three_words_prob = 0.15
    four_words_prob = 0.2

    for word in words:
        word_length = len(word)

        if word_length == 1 and random.random() < single_word_prob:
            if current_line:
                cleaned_line = clean_punctuation(current_line)
                if cleaned_line:
                    lines.append(cleaned_line)
                current_line = ""
            lines.append(word)
        elif word_length == 2 and random.random() < two_words_prob:
            if current_line:
                cleaned_line = clean_punctuation(current_line)
                if cleaned_line:
                    lines.append(cleaned_line)
                current_line = ""
            lines.append(word)
        elif word_length == 3 and random.random() < three_words_prob:
            if current_line:
                cleaned_line = clean_punctuation(current_line)
                if cleaned_line:
                    lines.append(cleaned_line)
                current_line = ""
            lines.append(word)
        elif word_length == 4 and random.random() < four_words_prob:
            if current_line:
                cleaned_line = clean_punctuation(current_line)
                if cleaned_line:
                    lines.append(cleaned_line)
                current_line = ""
            lines.append(word)
        else:
            if len(current_line) + word_length > 8:
                cleaned_line = clean_punctuation(current_line)
                if cleaned_line:
                    lines.append(cleaned_line)
                current_line = word
            else:
                current_line += word
    
    if current_line:
        cleaned_line = clean_punctuation(current_line)
        if cleaned_line:
            lines.append(cleaned_line)

    return lines


def clean_punctuation(text):
    while text and text[0] in PUNCTUATION:
        text = text[1:]
    while text and text[-1] in PUNCTUATION:
        text = text[:-1]

    if not text or all(char in PUNCTUATION for char in text):
        return ""
    
    return text


def calculate_text_size(draw, text, font):
    bbox = draw.textbbox((0, 0), text, font=font)
    text_width = bbox[2] - bbox[0]
    text_height = bbox[3] - bbox[1]
    return text_width, text_height


def calculate_average_color(image):
    stat = ImageStat.Stat(image)
    avg_color = stat.mean[:3]
    return avg_color


def choose_text_color(background_color):
    brightness = (background_color[0] * 299 + background_color[1] * 587 + background_color[2] * 114) / 1000
    if brightness > 180:
        return (0, 0, 0)  # 黑色
    else:
        return (255, 255, 255)  # 白色


def add_shadow(draw, position, text, font, text_color, shadow_color):
    x, y = position
    draw.text((x + 2, y + 2), text, font=font, fill=shadow_color)


def generate_random_background(image_width, image_height):
    """
    随机生成信笺风格的背景
    """
    # 增加更多随机浅色系背景颜色
    background_colors = [
    (255, 250, 240), (248, 244, 232), (240, 230, 210), (255, 245, 238), (250, 240, 230),
    (255, 248, 220), (253, 245, 230), (245, 245, 220), (230, 230, 250),
    
    # 额外的淡色背景颜色
    (255, 255, 240), (250, 250, 210), (255, 239, 219), (255, 240, 245), (255, 240, 255),
    (250, 240, 255), (245, 255, 250), (240, 255, 255), (240, 255, 240), (255, 255, 224),
    (253, 245, 230), (245, 255, 250), (250, 250, 250), (255, 250, 250), (255, 255, 255),
    (250, 240, 255), 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

爱钓鱼的程序员老周

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值