
A Python tool for collecting comments from Instagram posts. This tool allows you to efficiently gather comments data and save it in CSV format for further analysis.
- 🔍 Collect comments from any public Instagram post
- 💾 Save comments data in CSV format
- ⚡ Fast and efficient data collection
- 🔄 Rate limit handling
- 📊 Progress tracking
- 🎯 Limit number of comments to collect
- 🔑 Session ID management via .env file
- Python 3.6+
- Required Python packages:
requests python-dotenv
-
Clone this repository
git clone https://github.com/Xractz/instagram-comments-harvester.git cd instagram-comments-harvester
-
Install required packages
pip install -r requirements.txt
Before using the tool, you need to configure your Instagram session ID. You can do this in two ways:
-
Using the command line flag:
python harvest.py -s "your_session_id_here"
-
Manually creating a .env file:
session_id=your_session_id_here
- Log in to Instagram in your web browser
- Open the browser's Developer Tools (F12)
- Go to Application/Storage > Cookies
- Find the 'sessionid' cookie
- Copy the value
# Collect comments from a post (default: 100 comments)
python harvest.py -u https://www.instagram.com/p/XXXX
# Collect specific number of comments
python harvest.py -u https://www.instagram.com/p/XXXX -l 500
# Set session ID and collect comments
python harvest.py -s "your_session_id" -u https://www.instagram.com/p/XXXX -l 500
Flag | Description |
---|---|
-u , --url |
Instagram post URL to scrape comments from |
-l , --limit |
Maximum number of comments to collect (default: 100) |
-s , --sessionid |
Instagram session ID (will be saved to .env file) |
The tool saves comments in CSV format with the following naming convention:
results/[username]_[post_id]_comments_[timestamp].csv
comment_id
: Unique identifier for the commentmedia_id
: Instagram post identifierusername
: Commenter's usernamefull_name
: Commenter's full namecomment_text
: Content of the commentcreated_at
: Comment timestamplikes_count
: Number of likes on the comment
- This tool is for educational purposes only
- Respect Instagram's rate limits and terms of service
- Be mindful of Instagram's usage policies
- Your session ID is sensitive information - keep it secure
- The tool includes built-in delays to avoid rate limiting
This project is open for everyone! We welcome contributions of all kinds. Here's how you can help:
- 🐛 Report bugs and issues
- 💡 Suggest new features or improvements
- 📚 Improve documentation
- 🔧 Submit pull requests
- 👨💻 Review code changes
- ⭐ Star the project if you find it useful
For substantial changes, please open an issue first to discuss what you would like to change.