ReelScraper
Scrape Instagram Reels data with ease—be it a single account or many in parallel—using Python, threading, robust logging, and optional database support.
Installation • Usage • Classes • Documentation • Contributing • License • Acknowledgments • Disclaimer
💻 Installation
Requires Python 3.9+. Install directly from PyPI:
pip install reelscraper
Or clone from GitHub:
git clone https://github.com/andreaaazo/reelscraper.git
cd reelscraper
python -m pip install .
🚀 Usage
ReelScraper supports detailed logging and optional persistence via a database. You can either scrape a single Instagram account or handle multiple accounts concurrently.
1. Single-Account Scraping
Use ReelScraper to fetch Reels for a single account. Optionally pass a LoggerManager for retry logs and progress tracking.
from reelscraper import ReelScraper
from reelscraper.utils import LoggerManager
# Optional logger setup
logger = LoggerManager()
# Initialize scraper with a 30-second timeout, no proxy, and logging
scraper = ReelScraper(timeout=30, proxy=None, logger_manager=logger)
# Fetch up to 10 reels for "someaccount"
reels_data = scraper.get_user_reels("someaccount", max_posts=10)
for reel in reels_data:
print(reel)
2. Multi-Account Concurrency & Database Storage
Use ReelMultiScraper to process many accounts concurrently. Configure logging (LoggerManager) and database persistence (DBManager) if desired.
from reelscraper import ReelScraper, ReelMultiScraper
from reelscraper.utils import LoggerManager
from reelscraper.utils.database import DBManager
# Configure logger and optional DB manager
logger = LoggerManager()
db_manager = DBManager(db_url="sqlite:///myreels.db")
# Create a single scraper instance
single_scraper = ReelScraper(timeout=30, proxy=None, logger_manager=logger)
# MultiScraper for concurrency, database integration, and auto-logging
multi_scraper = ReelMultiScraper(
single_scraper,
max_workers=5,
db_manager=db_manager,
)
# File contains one username per line, e.g.:
# user1
# user2
accounts_file_path = "accounts.txt"
# Scrape accounts concurrently
# If DBManager is provided, results are stored in DB, and this method returns None
all_reels = multi_scraper.scrape_accounts(
accounts_file=accounts_file_path,
max_posts_per_profile=20,
max_retires_per_profile=10
)
if all_reels is not None:
print(f"Total reels scraped: {len(all_reels)}")
else:
print("All reels have been stored in the database.")
Note: If
DBManageris set, scraped reels are saved to the database instead of being returned.
🏗 Classes
ReelScraper
- Purpose:
Fetches Instagram Reels for a single user session. - Key Components:
InstagramAPI: Manages HTTP requests and proxy usage.Extractor: Structures raw reel data.LoggerManager(optional): Logs retries and status events.
- Key Method:
get_user_reels(username, max_posts=50, max_retries=10): Retrieves reels, handling pagination and retries.
ReelMultiScraper
- Purpose:
Scrapes multiple accounts in parallel, powered by a singleReelScraperinstance. - Key Components:
ThreadPoolExecutor: Enables concurrent scraping.AccountManager: Reads accounts from a local file.LoggerManager(optional): Captures multi-account events.DBManager(optional): Saves aggregated results to a database.
- Key Method:
scrape_accounts(accounts_file, max_posts_per_profile, max_retires_per_profile): Concurrently processes all accounts found in the file, optionally storing results in a DB.
📄 Documentation
Find full usage details in the DOCS.md file.
🤝 Contributing
We welcome PRs that enhance features, fix bugs, or improve docs.
- Fork the repo.
- Create a new branch.
- Commit code changes (add tests where possible).
- Open a pull request.
Your contributions are appreciated—happy coding!
📄 License
Licensed under the MIT License. Feel free to modify and distribute, but please be mindful of best practices and ethical scraping.
🙏 Acknowledgments
- Python Community: For making concurrency and requests straightforward to implement.
- Instagram: For providing reel content that inspires creativity.
- Beverages: For fueling late-night debugging and coding sessions.
⚠ Disclaimer
This software is for personal and educational purposes only. Use it in accordance with Instagram’s Terms of Service. We do not promote or condone large-scale commercial scraping or any violation of privacy/IP rights.
Enjoy scraping, and may your concurrency be swift!
Metadata
Release files for reelscraper 2.2.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| reelscraper-2.2.2.tar.gz | 34.2 kB | With provenance | Details for reelscraper-2.2.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| reelscraper-2.2.2-py3-none-any.whl | Python 3 | none | any | Details for reelscraper-2.2.2-py3-none-any.whl |
Total release size: 53.3 kB
Release files / reelscraper-2.2.2.tar.gz
| Download URL | reelscraper-2.2.2.tar.gz |
|---|---|
| Size | 34.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
15e9410a88908e753bc7e832919c90f81ac975285476fc51155ba855bce04783
|
|
BLAKE2b-256 checksum How to use checksums |
63adb1d6bc0a7c96218f33a7c89d74471ce72e4dcf5d64b08880e11dc42ecd29
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.0.1 CPython/3.12.8
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jan 15, 2025.
Transparency logRelease files / reelscraper-2.2.2-py3-none-any.whl
| Download URL | reelscraper-2.2.2-py3-none-any.whl |
|---|---|
| Size | 19.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
27655d843a89549caff089e83bba3b6808dd8579d55fc2c8f984ee9c96cbd0d0
|
|
BLAKE2b-256 checksum How to use checksums |
b7ef9f17d164c183da2e5f593ebe44ead05ed23a1a36f49f770f46f3299c4dd0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.0.1 CPython/3.12.8
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jan 15, 2025.
Transparency logSecurity for reelscraper 2.2.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for reelscraper-2.2.2.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jan 15, 2025.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.