Scrape TikTok and Instagram profiles by username and month to measure engagement rate. Collects views, likes, comments, and ER per post.
- TikTok β scrapes all posts for a given month, includes views, likes, comments, shares, and engagement rate. Optional account-level ER based on last 30 posts.
- Instagram β scrapes posts for a given month via a real browser session (Playwright). Includes post type (Photo / Video / Reel / Carousel), views (videos/reels), likes, and comments.
- Runs a hidden Chrome browser in the background β no visible popup.
- Session is saved after first Instagram login (paste
sessionidonce). - Export results as CSV per user or combined.
- Python 3.10+
- Playwright browsers installed
pip install -r requirements.txt
playwright install chromiumstreamlit run app.pyOpen http://localhost:8501, select a source, enter usernames (one per line, no @), pick a month, and click Scrape.
python harvester.py username1 username2 --month 2026-03
python harvester.py roihan_jnr --month 2026-04 --output april.csv| Flag | Description |
|---|---|
--month / -m |
Month to scrape in YYYY-MM format (required) |
--output / -o |
CSV output file (default: tiktok_YYYY_MM.csv) |
--sessions / -s |
Number of parallel browser sessions (default: 1) |
Instagram requires a sessionid cookie from a logged-in browser session.
- Open instagram.com in Chrome while logged in
- Open DevTools β Application β Cookies β
https://www.instagram.com - Copy the value of the
sessionidcookie - Paste it into the app when prompted
The session is saved to ~/.config/ig_scraper_session.json and reused automatically. Use the Log out button in the app to clear it.
Instagram account safety
Instagram actively detects and bans accounts that show unusual automation behavior. Do not use your personal or main business Instagram account. Create a dedicated burner account specifically for scraping. If that account gets banned or challenged, simply create a new one β your real account stays safe.
- Scraping too many accounts in a short time increases ban risk. Space out your requests.
- If Instagram triggers a security challenge (email/phone verification), the session will be invalidated and you will need to re-login with a fresh
sessionid. - TikTok scraping does not require any account β the browser session is anonymous.
| Field | TikTok | |
|---|---|---|
| Date | β | β |
| Post Type | β | β (Photo / Video / Reel / Carousel) |
| Views | β | β (videos/reels only) |
| Likes | β | β |
| Comments | β | β |
| Shares | β | β |
| View Eng. Rate % | β | β |
| Caption | β | β |
| Followers | β | β |

