SuperAPI AI Directory

zsxq-tuwen-likes-export

Data & analytics

View repository

Updated 10-16 09:59

About this skill

Knowledge Planet Image-and-Text Like Statistics Export

Core Principles

  • The user must first provide a roundup thread: usually https://articles.zsxq.com/id_xxx.html, but it can also be a Knowledge Planet topic link.
  • You must first read the roundup thread and display the image-and-text topic list, and only count likes after the user confirms.
  • When confirming, you must explain the counting rules; if the list does not match the user's expectations, remind the user to modify the roundup thread content format themselves, then re-read the preview.
  • Do not guess link attribution based on dates, subheadings, adjacent lines, or context. When the format is non-standard, do not manually add links.
  • Before confirmation, only do a list preview; after confirmation, fetch the current like counts according to the confirmed preview JSON and export a CSV.

Counting Rules

The default rules must be told to the user verbatim:

  1. Parse the roundup thread content paragraph by paragraph/line by line.
  2. Only include links that, within the same paragraph/same line, contain both 图文 and a Knowledge Planet link.
  3. t.zsxq.com Short links resolve via redirect to topic_id;wx.zsxq.com topic links resolve directly to topic_id。
  4. When there are multiple Knowledge Planet topic links in the same line, include all of them.
  5. Non-Knowledge Planet links such as WeChat Channels, Official Accounts, and external web pages are not included.
  6. If 图文 and the link are split across different lines, they are not included by default; ask the user to first modify the roundup thread format themselves, then preview again.
  7. The like count comes from the counts.likescurrently returned by the topic detail API, and the result will change as the user likes posts later.

Quick Process

  1. Confirm that the user has provided a roundup thread URL; if not, first ask the user to provide one.
  2. Run the preview command:
    SKILL_DIR="$HOME/.codex/skills/zsxq-tuwen-likes-export"
    python3 "$SKILL_DIR/scripts/tuwen_likes_export.py" preview \
      --source-url '<汇总贴URL>' \
      --out-dir outputs \
      --prefix summary
    
  3. Open the *_preview.md output by the script or read the terminal summary, and send the image-and-text topic list and the above counting rules to the user for confirmation.
  4. If the user points out omissions or attribution errors, do not continue counting; remind the user to first modify the roundup thread so that each image-and-text item and its corresponding link are in the same paragraph/same line, then run the preview again.
  5. After the user explicitly confirms it is correct, run the export command:
    SKILL_DIR="$HOME/.codex/skills/zsxq-tuwen-likes-export"
    python3 "$SKILL_DIR/scripts/tuwen_likes_export.py" export \
      --preview-json outputs/summary_tuwen_preview.json \
      --out-dir outputs \
      --prefix summary
    
  6. Validate the CSV:
    python3 - <<'PY'
    import csv
    detail=list(csv.DictReader(open('outputs/summary_tuwen_like_details.csv', encoding='utf-8-sig')))
    summary=list(csv.DictReader(open('outputs/summary_tuwen_likes_by_author.csv', encoding='utf-8-sig')))
    print(len(detail), len(summary))
    print(sum(int(r['likes_count']) for r in detail), sum(int(r['total_likes']) for r in summary))
    print(all(r['fetch_success'] == 'True' for r in detail))
    PY
    

Output Files

Preview stage:

  • <prefix>_tuwen_preview.json: candidate topic list for confirmation; the export stage must use this file.
  • <prefix>_tuwen_preview.md: Markdown list for the user to confirm.

Export stage:

  • <prefix>_tuwen_like_details.csv: image-and-text details, including topic, author, likes, comments, reads, link, and source line.
  • <prefix>_tuwen_likes_by_author.csv: summary by author, including topic count, total likes, average likes, highest likes, total comments, and total reads.
  • <prefix>_tuwen_export.json: export diagnostic data, useful for troubleshooting field or API issues.

Common Issues

  • The preview list is missing an item: usually 图文 and the Knowledge Planet link are not in the same paragraph/same line. Have the user modify the roundup thread format and rerun the preview.
  • The preview list has an extra item: usually a line contains both 图文 and multiple Knowledge Planet links. Have the user adjust the roundup thread and move links that should not be counted out of that line.
  • A short link cannot be resolved: rerun the preview; if it still fails, ask the user to replace the short link with a wx.zsxq.com topic link and try again.
  • The like count is inconsistent with what is seen on the page: use the current value returned by the topic detail API at export time as the source of truth, and check whether a new like was just added or there is cache delay.