home / skills / aidotnet / moyucode / x-report-generator

x-report-generator skill

/skills/tools/x-report-generator

This skill analyzes X data via Playwright, generates a polished HTML report panel, and exports high-resolution images for social media insights.

npx playbooks add skill aidotnet/moyucode --skill x-report-generator

Review the files below or copy the command above to add this skill to your agents.

Files (2)
SKILL.md
2.1 KB
---
name: x-report-generator
description: 使用Playwright浏览器爬取X(Twitter)真实数据,分析统计信息,生成精美的HTML报告面板并导出为高清图片。
metadata:
  short-description: X数据分析报告生成器
source:
  repository: https://github.com/AmineDiro/twitter-scraper
  license: MIT
---

# X Report Generator Tool

## Description
使用Playwright浏览器自动化技术爬取X(Twitter)平台的真实数据,进行数据分析和统计,生成精美的HTML可视化报告面板,并将其渲染为高清图片。

## Features
- 🔍 关键词搜索推文(真实爬取)
- 👤 用户推文分析
- 📊 数据统计分析(互动量、时间分布、情感分析等)
- 🎨 精美HTML报告面板(深色/浅色主题)
- 🖼️ HTML转高清PNG图片导出
- 🍪 支持Cookies登录状态保存

## Trigger
- `/x-report` command
- 用户需要分析X平台数据
- 用户想生成社交媒体报告

## Usage

```bash
# 首次使用:登录并保存cookies
python scripts/x_report_generator.py login --cookies cookies.json

# 搜索关键词并生成报告
python scripts/x_report_generator.py search "AI" --limit 50 --output report.png --cookies cookies.json

# 分析用户推文
python scripts/x_report_generator.py user "elonmusk" --limit 30 --output user_report.png

# 使用浅色主题
python scripts/x_report_generator.py search "Python" --theme light --output report.png

# 仅生成HTML(不转图片)
python scripts/x_report_generator.py search "coding" --html-only --output report.html

# 显示浏览器窗口(调试用)
python scripts/x_report_generator.py search "test" --no-headless --output report.png
```

## Requirements

```bash
pip install playwright
playwright install chromium
```

## 报告内容

- 📈 推文总数、点赞、转发、评论、浏览统计
- ⏰ 24小时发布时间分布图
- 😊 情感分析(正面/中性/负面)
- 🏷️ 热门标签云
- 👥 活跃用户 TOP 5
- 🔥 热门推文展示

## Tags
`twitter`, `x`, `scraper`, `report`, `analytics`, `visualization`, `playwright`, `html-to-image`

## Compatibility
- Codex: ✅
- Claude Code: ✅

Overview

This skill automates the collection and analysis of real X (Twitter) data using a Playwright browser, then builds a polished HTML dashboard and exports it as a high-resolution image. It supports keyword searches, user timeline analysis, engagement and time-distribution stats, sentiment breakdowns, tag clouds, and exportable reports in dark or light themes. Cookie-based login persists sessions for authenticated data access.

How this skill works

The tool drives a headless or visible Chromium instance via Playwright to fetch live posts and metadata from X. It aggregates metrics (likes, reposts, replies, impressions when available), runs basic sentiment analysis and time-series grouping, renders an HTML visualization panel, and converts that panel into a PNG image. Optional flags control limits, themes, headless mode, and whether to output raw HTML instead of an image.

When to use it

  • When you need a quick social listening snapshot for a keyword or hashtag on X
  • When preparing client-ready visuals summarizing X engagement and trends
  • When auditing a specific user account’s posting behavior and interactions
  • When you want printable or shareable high-resolution report images
  • When collecting real-world sample posts for research or competitive analysis

Best practices

  • Save and reuse authenticated cookies to avoid repeated logins and rate issues
  • Start with a reasonable result limit (e.g., 50–200) to balance completeness and speed
  • Use headful mode for debugging visual scraping issues, then switch to headless for production
  • Respect platform terms and throttling: add delays or lower concurrency to reduce detection
  • Validate sentiment outputs on a sample set; tune or replace the analyzer if needed

Example use cases

  • Generate a weekly keyword report for a marketing campaign and export a PNG for slide decks
  • Analyze a competitor’s last 30 posts to surface peak posting times and most engaging content
  • Produce a sentiment and tag-cloud summary before a product launch to inform messaging
  • Export an HTML snapshot for archival purposes and create a high-resolution image for social sharing
  • Run ad-hoc investigations into trending posts and save the visual dashboard for team review

FAQ

Can this run without logging in?

Yes for some public content, but logging in with saved cookies yields more complete results and access to authenticated metrics.

Is the exported image suitable for print or slides?

Yes. The reporter renders a high-resolution PNG intended for presentations and print-ready assets.

How do I change theme or output type?

Use the theme flag (light/dark) and the html-only flag to control whether you get HTML or a rendered image.