𝕷𝖎𝖑𝖏𝖆𝖈𝖐 发表于 2024-8-24 13:31:26

分享个火车头的脚本 随机打乱句子顺序

现在百度收录真的很难,不想被割就不要轻易尝试那些收录大法。传说,越是看不懂的越容易收录。闲来无事,发个火车头的C#脚本,随机打乱语句顺序,造呗,反正也不收录。


using System;using System.Collections.Generic;using System.Text.RegularExpresions;using SpiderInterface;class LocoyCode{    private static Random random = new Random();    // 运行方法,接受HTML内容和响应对象,返回处理后的结果    public string Run(string content, ResponseEntry response)    {      string result = ShuffleSentencesWithinTags(content);      return result;    }    // 在标签内部打乱句子的方法    private string ShuffleSentencesWithinTags(string content)    {      string pattern = @"<p>(.*)<\/p>"; // 匹配<p>标签内的内容      MatchCollection matches = Regex.Matches(content, pattern);      foreach (Match match in matches)      {            string sentence = match.Groups.Value; // 获取匹配到的句子内容            string shuffledSentence = ShuffleSentences(sentence); // 打乱句子            // 替换原文本中的句子为打乱后的句子            content = content.Remove(match.Index, match.Length)                .Insert(match.Index, "" + shuffledSentence + "");      }      return content;    }    // 打乱句子的方法    private string ShuffleSentences(string text)    {      string[] sentences = Regex.Split(text, @"(?<=[。,!?、:;])"); // 使用标点符号分割句子      if (sentences.Length > 0)      {            List<string> shuffledSentences = new List<string>(sentences);            shuffledSentences.Shuffle(random); // 打乱句子顺序            string modifiedSentence = string.Join("", shuffledSentences); // 重新组合句子            return modifiedSentence;      }      return text;    }}// 扩展方法用于列表随机打乱public static class ListExtensions{    public static void Shuffle<T>(this IList<T> list, Random rng)    {      int n = list.Count;      while (n > 1)      {            n--;            int k = rng.Next(n + 1);            T value = list;            list = list;            list = value;      }    }}
页: [1]
查看完整版本: 分享个火车头的脚本 随机打乱句子顺序

创宇盾启航版免费网站防御网站加速服务