Python library for scraping anime websites, currently supporting AnimeFLV and JKAnime.
Project description
Ani Scrapy
Ani-Scrapy is a Python library for scraping anime websites, designed to provide both synchronous and asynchronous interfaces. It currently supports AnimeFLV and JKAnime, and makes it easy to switch between different platforms.
Ani-Scrapy helps developers automate anime downloads and build applications. It provides detailed anime and episode information, along with download links from multiple servers, supporting dynamic and static content across several sites.
🚀 Features
Core Functionality
- Dual Interface: Synchronous and asynchronous APIs for flexible integration.
- Multi-Platform Support: Unified interface for different platforms.
- Comprehensive Data: Detailed anime metadata, episode information, and download links.
Content Handling
- Static Content Extraction: Direct server links using
request + cloudscraper + curl_cffi + aiohttp + bs4 - Dynamic Content Processing: JavaScript-rendered links using
Playwright - Mixed Approach: Smart fallback between static and dynamic methods
Technical Capabilities
- Concurrent Scraping: Built-in support for asynchronous batch processing
- Automatic Resource Management: Browser instances handled automatically when not provided
- Custom Browser Support: Configurable browser paths and headless/headed modes via
executable_pathandheadlessoptions
Development Experience
- Modular Design: Easy to extend with new scrapers and platforms
- Configurable Logging: Verbose mode and multiple log levels (
DEBUG,INFO,SUCCESS,WARNING,ERROR) - Performance Optimization: Connection reuse and caching capabilities
📦 Installation
From PyPI:
pip install ani-scrapy
From GitHub:
pip install git+https://github.com/ElPitagoras14/ani-scrapy.git
Development Installation:
git clone https://github.com/ElPitagoras14/ani-scrapy.git
cd ani-scrapy
pip install -e .
playwright install chromium
🐍 Requirements
- Python >= 3.9 (tested with 3.12)
Install Chromium (only once):
playwright install chromium
📊 Supported Websites
Currently Supported
- AnimeFLV: Full support
- JKAnime: Supports search, info, table downloads, file downloads |
iframe downloads
🚀 Basic Usage
Asynchronous API Example
from ani_scrapy.async_api import AnimeFLVScraper, JKAnimeScraper, AsyncBrowser
import asyncio
async def main():
# Initialize scrapers
animeflv_scraper = AnimeFLVScraper(verbose=True)
jkanime_scraper = JKAnimeScraper(verbose=True)
# Search anime
an_results = await animeflv_scraper.search_anime(query="naruto", page=1)
jk_results = await jkanime_scraper.search_anime(query="naruto")
print(f"AnimeFLV results: {len(an_results.animes)} animes found")
print(f"JKAnime results: {len(jk_results.animes)} animes found")
# Get anime info
an_info = await animeflv_scraper.get_anime_info(
anime_id=an_results.animes[0].id
)
jk_info = await jkanime_scraper.get_anime_info(
anime_id=jk_results.animes[0].id
)
print(f"AnimeFLV info: {an_info.title}")
print(f"JKAnime info: {jk_info.title}")
# Get download links (with browser for dynamic content)
async with AsyncBrowser(headless=False) as browser:
# Table download links
an_table_links = await animeflv_scraper.get_table_download_links(
anime_id=an_info.id, episode_id=1
)
jk_table_links = await jkanime_scraper.get_table_download_links(
anime_id=jk_info.id, episode_id=1, browser=browser
)
# Iframe download links (requires browser for JS content)
an_iframe_links = await animeflv_scraper.get_iframe_download_links(
anime_id=an_info.id, episode_id=1, browser=browser
)
# Get final file download links
if an_iframe_links.download_links:
file_links = await animeflv_scraper.get_file_download_link(
download_info=an_iframe_links.download_links[0],
browser=browser,
)
print(f"Download URL: {file_links.url}")
if __name__ == "__main__":
asyncio.run(main())
Synchronous API Example
from ani_scrapy.sync_api import AnimeFLVScraper, JKAnimeScraper, SyncBrowser
# Initialize scrapers
animeflv_scraper = AnimeFLVScraper(verbose=True)
jkanime_scraper = JKAnimeScraper(verbose=True)
# Search anime
an_results = animeflv_scraper.search_anime(query="naruto", page=1)
jk_results = jkanime_scraper.search_anime(query="naruto")
print(f"AnimeFLV results: {len(an_results.animes)} animes found")
print(f"JKAnime results: {len(jk_results.animes)} animes found")
# Get anime info
an_info = animeflv_scraper.get_anime_info(anime_id=an_results.animes[0].id)
jk_info = jkanime_scraper.get_anime_info(anime_id=jk_results.animes[0].id)
print(f"AnimeFLV info: {an_info.title}")
print(f"JKAnime info: {jk_info.title}")
# Get download links with browser for dynamic content
with SyncBrowser(headless=False) as browser: # Table download links
an_table_links = animeflv_scraper.get_table_download_links(
anime_id=an_info.id, episode_id=1
)
jk_table_links = jkanime_scraper.get_table_download_links(
anime_id=jk_info.id, episode_id=1, browser=browser
)
# Iframe download links (requires browser for JS content)
an_iframe_links = animeflv_scraper.get_iframe_download_links(
anime_id=an_info.id, episode_id=1, browser=browser
)
# Get final file download links
if an_iframe_links.download_links:
file_links = animeflv_scraper.get_file_download_link(
download_info=an_iframe_links.download_links[0], browser=browser
)
print(f"Download URL: {file_links.url}")
📖 API Reference
For complete documentation: API Reference
Methods Overview:
search_anime- Search for animeget_anime_info- Get detailed anime informationget_table_download_links- Get direct server linksget_iframe_download_links- Get iframe linksget_file_download_link- Get final download URL
Browser Classes:
AsyncBrowser- Automatic resource management for async operationsSyncBrowser- Context manager for synchronous scraping
🛠️ Advanced Usage
Custom Browser Configuration
from ani_scrapy import AsyncBrowser, SyncBrowser
# Custom Brave browser path
brave_path = ""
async with AsyncBrowser(
headless=False,
executable_path=brave_path,
) as browser:
# Your scraping code here
pass
Error Handling Example
try:
results = await scraper.search_anime("naruto")
if results.animes:
anime_info = await scraper.get_anime_info(results.animes[0].id)
print(f"Success: {anime_info.title}")
except Exception as e:
print(f"Error occurred: {e}")
# Implement retry logic or fallback here
Concurrent Scraping
import asyncio
async def scrape_multiple_animes(anime_ids):
tasks = []
for anime_id in anime_ids:
task = scraper.get_anime_info(anime_id)
tasks.append(task)
results = await asyncio.gather(*tasks, return_exceptions=True)
return results
🤝 Contributing
Contributions to Ani-Scrapy are welcome! You can help by:
- Reporting bugs or suggesting new features via GitHub Issues.
- Improving documentation.
- Adding new scrapers or enhancing existing ones.
- Writing tests to ensure code quality.
How to contribute
- Fork the repository.
- Create a new branch for your feature or fix:
git checkout -b my-feature
- Make your changes and commit with clear messages.
- Push your branch to your fork.
- Open a Pull Request against the
mainbranch of the original repository.
Please ensure that all tests pass before submitting a PR. Contributions are expected to respect the license and coding style.
🧪 Development and Testing
Install development dependencies:
pip install -r requirements.txt
🚧 Coming Soon
Support for more anime websites and further unification of scraper methods is planned.
If you want to contribute by adding new scrapers for other sites, contributions are welcome!
⚠️ Disclaimer
This library is intended for educational and personal use only. Please respect the terms of service of the websites being scraped and the applicable laws. The author is not responsible for any misuse.
📄 License
MIT © 2025 El Pitágoras
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ani_scrapy-0.1.5.tar.gz.
File metadata
- Download URL: ani_scrapy-0.1.5.tar.gz
- Upload date:
- Size: 28.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
70983ed5602020e562d6c9c3ff3047922dfd4e287969162b5954685c475837dc
|
|
| MD5 |
b67cd6f7da0451aecd364231370acd82
|
|
| BLAKE2b-256 |
bbc51d96c73e4a37fbd57f44eed21d7cd2e686e3887f5d8f41011b41fe18a5f6
|
File details
Details for the file ani_scrapy-0.1.5-py3-none-any.whl.
File metadata
- Download URL: ani_scrapy-0.1.5-py3-none-any.whl
- Upload date:
- Size: 33.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d7ee91b32dca4a39ecea429e06e755ed1ab5097b3a43cd91547f798870d4fdd1
|
|
| MD5 |
4b98e339674ddd0d28d5add7bb2ad9c1
|
|
| BLAKE2b-256 |
0540b6abc34f0b93ffeef483c2fd22387053fdd823856362c86d4ebf51dd7c7e
|