philyuchkoff/Cyclops

GitHub: philyuchkoff/Cyclops

一款通过关键词同时监控 Telegram 频道和 RSS 源、自动去重并生成精美 HTML 报告的命令行信息聚合工具。

Stars: 0 | Forks: 0

# 👁️ Cyclops - 互联网通用监控工具 **Cyclops** 是一款用于监控互联网的命令行工具。它会自动扫描 Telegram 频道和 RSS 订阅源,根据指定的关键字查找新闻,并生成精美的 HTML 报告。 ## ✨ 功能 - 🔍 **关键字搜索** — 查找任何主题:禁令、封锁、AI 新闻、数据泄露等。 - **Telegram 集成** — 读取公开频道(通过 Telethon) - **RSS 支持** — 解析任何 RSS 订阅源 - **日期过滤** — 仅获取过去 N 天的新闻(默认为 30 天) - **防重复** — 使用 SQLite 数据库存储哈希值,相同的新闻不会重复出现在报告中 - **精美的 HTML 报告** — 时尚的卡片式设计,按日期排序 - **灵活配置** — 支持 JSON 配置文件、环境变量和 CLI 参数 ## 安装 ### 1. 克隆仓库 ``` git clone https://github.com/philyuchkoff/cyclops.git cd cyclops ``` ### 2. 安装依赖 ``` pip install feedparser beautifulsoup4 telethon python-dateutil ``` ### 3.(可选)配置 Telegram 要使用 Telegram,需要获取 API 数据: 1. 访问 https://my.telegram.org/apps 2. 使用您的账号登录 3. 创建一个应用(App title: "Cyclops" 或其他任意名称) 4. 复制 `api_id` 和 `api_hash` 5. 配置环境变量: ``` export TG_API_ID=api_id export TG_API_HASH=api_hash export TG_PHONE=+79123456789 ``` 或者创建一个 `.env` 文件: ``` TG_API_ID=api_id TG_API_HASH=api_hash TG_PHONE=+79123456789 ``` ## 使用方法 ### 方式 1:通过配置工具(推荐) 创建一个包含关键字的配置: ``` # 最简单的 config python config.py запрет блокировка ограничение --name my_monitor # 带 Telegram 频道 python config.py запрет блокировка --channels rian_ru,breakingmash --name monitor # 带 RSS 订阅源 python config.py "искусственный интеллект" --rss "TechCrunch=https://techcrunch.com/feed" --name ai_news # 最近 7 天 python config.py запрет --days 7 --name short_monitor ``` ### 运行 ``` python cyclops.py my_monitor.json ``` ### 方式 2:不使用配置工具 ``` python cyclops.py --keywords "запрет,блокировка" --channels "rian_ru,breakingmash" --rss "РИА=https://ria.ru/export/rss2/index.xml" ``` ## config.py - 创建配置 ``` python config.py [ключевые_слова] [опции] ``` ### 必需参数 `ключевые_слова` - 用于搜索的单词或短语(可以加引号) ### 选项 `--name`, `-n` - 配置文件名(默认:`my_monitor`) `--targets`, `-t` - 搜索目标(默认:соцсети,telegram,youtube,интернет) `--channels`, `-ch` - 逗号分隔的 Telegram 频道(不带 `@`) `--rss`, `-r` - RSS 订阅源,格式为:`name=url,name2=url2` `--days`, `-d` - 往前推算的天数(默认:30) `--limit`, `-l` - 每个频道的消息限制(默认:50) `--no-telegram` - 禁用 Telegram `--no-rss` - 禁用 RSS `--list` - 显示所有现有配置 ### 示例 ``` # 基础 config python config.py запрет блокировка --name my_config # 带引号中的短语 python config.py "искусственный интеллект" "data breach" --name security # 完整 config python config.py запрет ограничение \ --channels rian_ru,breakingmash \ --rss "РИА=https://ria.ru/export/rss2/index.xml,Лента=https://lenta.ru/rss" \ --days 14 \ --name full_monitor # 仅 RSS python config.py запрет --rss "Reuters=http://feeds.reuters.com/reuters/technologyNews" --no-telegram # config 列表 python config.py --list ``` ## cyclops.py - 运行 ``` python cyclops.py [конфиг.json] [опции] ``` ### 选项 `--config`, `-c` - JSON 配置文件路径 `--keywords`, `-k` - 覆盖默认关键字 `--channels`, `-ch` - 覆盖默认的 Telegram 频道 `--rss`, `-r` - 覆盖默认的 RSS 订阅源 `--days`, `-d` - 覆盖默认时间范围 `--sources`, `-s` - 指定使用的来源(telegram,rss) `--output`, `-o` - 输出的 HTML 文件名 `--no-html` - 不生成 HTML 报告 `--no-json` - 不生成 JSON 导出 `--clear-cache` - 清除重复缓存 ### 示例 ``` # 带 config python cyclops.py my_config.json # 仅从 config 读取 RSS python cyclops.py my_config.json --sources "rss" # 覆盖关键词 python cyclops.py my_config.json --keywords "запрет,блокировка,цензура" # 最近 7 天并清除缓存 python cyclops.py my_config.json --days 7 --clear-cache # 无 config,全部通过 CLI python cyclops.py --keywords "запрет" --channels "rian_ru" --rss "РИА=https://ria.ru/export/rss2/index.xml" ``` ## 常见问题与解决方案 ### Telegram 无法运行 出现 `⚠️ Telegram не настроен` 错误 1. 在 https://my.telegram.org/apps 获取 API 数据 2. 配置环境变量或将其添加到配置文件中 3. 首次运行时,输入来自 Telegram 的验证码 ### 找不到新闻 出现 `⚠️ Новых новостей не найдено` 错误 - 减小 `--days`(例如改为 7) - 添加更多关键字 - 检查来源(它们是否有效?) - 删除过于具体的词汇 ### 新闻重复 Cyclops 会通过 SQLite 自动过滤重复内容。如果需要重新开始收集: ``` python cyclops.py my_config.json --clear-cache ``` ### 收到 Telegram 的 FloodWait 限制 Telegram 会限制请求频率。脚本会自动等待指定的时间。请减少频道数量或增加请求之间的延迟。 ## 使用示例 ### 监控 AI 新闻 ``` python config.py "искусственный интеллект" "нейросети" "chatgpt" \ --targets "закон,регуляция,ограничение" \ --rss "TechCrunch=https://techcrunch.com/feed,Wired=https://www.wired.com/feed/rss" \ --no-telegram \ --name ai_news python cyclops.py ai_news.json ``` ### 每日监控 (cron) ``` # 创建 daily.sh 脚本 #!/bin/bash cd /path/to/cyclops python cyclops.py my_config.json --days 1 ``` 添加到 crontab: ``` 0 9 * * * /path/to/cyclops/daily.sh ``` ## 使用到的技术 - [Telethon](https://github.com/LonamiWebs/Telethon) 用于与 Telegram API 交互 - [feedparser](https://github.com/kurtmckee/feedparser) 用于解析 RSS - [BeautifulSoup4](https://www.crummy.com/software/BeautifulSoup/) 用于清理 HTML
标签:HTML报告, Python, RSS, Telegram, 无后门, 监控工具, 逆向工具