Use Cases
- The user says "help me search for Official Account articles/recent articles for a certain keyword"
- Need to quickly obtain: title, summary, publication time, Official Account name, accessible link
Workflow
Step 1: Confirm that the dependency package is installed
This script depends on the NodeJS dependency package cheerio. It is recommended to first perform a global installation or install it in the project:
npm install -g cheerio
Step 2: Confirm the number of search terms
1. Confirm the keyword and quantity
Step 3: Execute the search command
1. Execute a regular search command
node scripts/search_wechat.js "关键词"
Special Process (Optional)
- Execute a search command that includes a quantity limit
node scripts/search_wechat.js "关键词" -n 15
- If the user needs to save the results to a file, execute the command
node scripts/search_wechat.js "关键词" -n 20 -o result.json
- If you want to obtain the real link of the WeChat article domain, execute the following command
node scripts/search_wechat.js "关键词" -n 5 -r
Parameter Description
query: Search keyword (required)-n, --num: Return quantity (default 10, maximum 50)-o, --output: Output JSON file path (optional)-r, --resolve-url: Attempt to resolve the intermediate link into the real WeChat article link (will make an additional request for each result)
Output Fields (Article Object)
Article title, article address, article summary, publication time, source Official Account name
Common Issue Handling
- Empty results: Try changing the keyword, using fewer special characters, or retrying later
- Failed to resolve the real URL: This is normal (anti-scraping restrictions); you can prompt the user to open the intermediate link in a browser
Notes
- This tool is for learning and research purposes only. Do not use it for commercial purposes or large-scale scraping.
- When using this tool, please comply with the terms of use and regulations of the relevant websites.
- Excessive use may result in IP bans. Please use it with caution.