Skip to main content

Python library for scraping anime websites, currently supporting AnimeFLV and JKAnime.

Project description

Ani Scrapy

PyPI Version

License

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_path and headless options

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 anime
  • get_anime_info - Get detailed anime information
  • get_table_download_links - Get direct server links
  • get_iframe_download_links - Get iframe links
  • get_file_download_link - Get final download URL

Browser Classes:

  • AsyncBrowser - Automatic resource management for async operations
  • SyncBrowser - 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

  1. Fork the repository.
  2. Create a new branch for your feature or fix:
git checkout -b my-feature
  1. Make your changes and commit with clear messages.
  2. Push your branch to your fork.
  3. Open a Pull Request against the main branch 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ani_scrapy-0.1.11.tar.gz (27.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ani_scrapy-0.1.11-py3-none-any.whl (33.9 kB view details)

Uploaded Python 3

File details

Details for the file ani_scrapy-0.1.11.tar.gz.

File metadata

  • Download URL: ani_scrapy-0.1.11.tar.gz
  • Upload date:
  • Size: 27.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.13

File hashes

Hashes for ani_scrapy-0.1.11.tar.gz
Algorithm Hash digest
SHA256 e99cf8ab629b33aa3cf8a15f7d14aadaa012bc456e9b5f99ff22dd22ed688c23
MD5 9bcd4a33c55f8c4aed2aa008a510f51b
BLAKE2b-256 e9cbb4bf355b09077f00a99900608139deb301fd308addb34f06ec2e7a579c16

See more details on using hashes here.

File details

Details for the file ani_scrapy-0.1.11-py3-none-any.whl.

File metadata

  • Download URL: ani_scrapy-0.1.11-py3-none-any.whl
  • Upload date:
  • Size: 33.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.13

File hashes

Hashes for ani_scrapy-0.1.11-py3-none-any.whl
Algorithm Hash digest
SHA256 47759e135372a0be33a9092c5dc143aa631e192069b37000a9fc70c225511ea8
MD5 9dd3284bfdd9c2c309d6e81dc143b63b
BLAKE2b-256 e91b5c4bd678a5c8ea831825f3e985c8bb53583b30eb60ebe6383c479161986b

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page