Applicable scenarios
- User says "help me search for Official Account articles/recent articles for a certain keyword"
- Need to quickly obtain: title, summary, publish time, Official Account name, accessible link
Workflow
Step 1: Confirm that dependency packages are 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 keywords and quantity
Step 3: Execute the search command
1. Execute the 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: number of results to return (default 10, maximum 50)-o, --output: output JSON file path (optional)-r, --resolve-url: try 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, publish time, source Official Account name
Common issue handling
- Empty results: try changing keywords, using fewer special characters, or retrying later
- Failed to resolve the real URL: this is normal (anti-crawling 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 crawling.
- When using this tool, please comply with the terms of use and regulations of the relevant websites.
- Excessive use may result in IP blocking; please use with caution.