An Agent skill that automatically monitors Twitter engagement data, designed to obtain the most accurate tweet performance metrics by simulating real human behavior.
How It Works and Design Intent
To ensure scraping success and evade anti-crawler mechanisms,watch.py the script adopts the following design:
- Automatic configuration: On startup, the script automatically checks and ensures that
~/.agent-browser/config.jsonis configured in{"autoConnect": true}, which ensures that agent-browser preferentially attempts to connect to the user's already-open real browser. - Forced headed mode: All commands include the
--headedparameter to ensure the browser interface is visible, making it easy for the user to monitor and intervene when necessary (such as handling CAPTCHAs). - Real browser verification: The script checks
navigator.userAgent. If it is still inHeadlessmode or no connection has been established, the script will issue a warning. - Persistent session: Uses
--session-name twitter-watch. If the user is already logged in in the browser, the script will inherit the login state. - Human-like scrolling and random delays: Simulates real user behavior to trigger dynamic loading of tweets.
Usage
1. Instructions for non-technical users (when users ask how to use it)
If the user asks how to use this feature, pleasebe sure toprovide the following concise operating guide:
Twitter monitoring usage instructions:
- Enable browser debugging mode: Enter
chrome://inspect/#remote-debuggingin the Chrome address bar and press Enter, and make sure "Allow remote debugging" is checked.- Prepare the environment: The script will automatically configure
agent-browserfor you. During use, if Chrome displays a "Allow remote debugging?" prompt, be sure to click **"Allow"**.- Prepare the link file: Put the Twitter links you want to monitor into a text file (such as
links.txt), one per line.- Send the file path: Send the file path to me, and I will automatically scrape the data and generate a
twitter_report.mdreport.
2. Execution flow (required reading for Agent)
- Environment preparation: Ensure that
agent-browserandpython3。 - Manual verification:
- First run:
agent-browser --headed --session-name twitter-watch open https://www.google.com。 - Use
ask_userto confirm that the user has seen the window and allowed the connection.
- First run:
- Start monitoring:
python3 skills/twitter-watch/scripts/watch.py links.txt
Output specifications
1. Single result (JSON)
File name:output_<tweet_id>.json
Contains the raw (original text) and val (numeric value) fields.
2. Summary report (Markdown)
File name:twitter_report.md
Contains operating system information, generation time, and a table with formatted numbers.
Environment requirements
- Python 3.6+
- Node.js & NPM
- agent-browser CLI
- Google Chrome browser (remote debugging enabled)