nyaascraper
is an asynchronous Python library for scraping nyaa.si and sukebei.nyaa.si.
Installing through pip:
pip install nyaascraper
By default, the site is nyaa.si (work-safe site).
from nyaascraper import NyaaClient, SITE
# Work-safe site. (Default)
client = NyaaClient(SITE.FUN)
# Non-work-safe site.
client = NyaaClient(SITE.FAP)
Changing the site of the client dynamically.
from nyaascraper import SITE
client.site = SITE.FUN
from nyaascraper.models import SearchResult
result: SearchResult = await client.search(term="...")
for torrent in result.torrents:
print(torrent)
result = await client.search(username="...")
print(result)
from nyaascraper import QualityFilter
# No Filter. (Default)
result = await client.search(quality_filter=QualityFilter.NO_FILTER)
print(result)
# Trusted only.
result = await client.search(quality_filter=QualityFilter.TRUSTED_ONLY)
print(result)
# No Remakes.
result = await client.search(quality_filter=QualityFilter.NO_REMAKES)
print(result)
from nyaascraper.enums import FunCategory, FapCategory
# Work-safe category.
result = await client.search(category=FunCategory.ANIME)
print(result)
# Work-safe subcategory search.
result = await client.search(category=FunCategory.ANIME_ENGLISH_TRANSLATED)
print(result)
# Non-work-safe category.
result = await client.search(category=FapCategory.ART)
print(result)
# Non-work-safe subcategory search.
result = await client.search(category=FapCategory.ART_MANGA)
print(result)
from nyaascraper.enums import SortBy, SortOrder
# Sort by comments.
result = await client.search(sort_by=SortBy.COMMENTS)
print(result)
# Sort by size.
result = await client.search(sort_by=SortBy.SIZE)
print(result)
# Sort by date.
result = await client.search(sort_by=SortBy.DATE)
print(result)
# Sort by seeders.
result = await client.search(sort_by=SortBy.SEEDERS)
print(result)
# Sort by leechers.
result = await client.search(sort_by=SortBy.LEECHERS)
print(result)
# Sort by downloads.
result = await client.search(sort_by=SortBy.DOWNLOADS)
print(result)
# Sort order: Ascending.
result = await client.search(sort_order=SortOrder.ASCENDING)
print(result)
# Sort order: Descending.
result = await client.search(sort_order=SortOrder.DESCENDING)
print(result)
result = await client.search(page=2)
print(result)
from nyaascraper.models import TorrentInfo
result = await client.search()
# Select View-ID of the first torrent from the search results.
view_id: int = result.torrents[0].view_id
torrent_info: TorrentInfo = await client.get_torrent_info(view_id)
print(torrent_info)
By default, the site is nyaa.si (work-safe site).
from nyaascraper import NyaaRSSClient, SITE
# Work-safe site. (Default)
client = NyaaRSSClient(SITE.FUN)
# Non-work-safe site.
client = NyaaRSSClient(SITE.FAP)
Changing the site of the client dynamically.
from nyaascraper import SITE
client.site = SITE.FUN
from nyaascraper.models import NyaaRSSFeed
feed: NyaaRSSFeed = await client.get_feed()
print("Title:", feed.title)
print("Description:", feed.description)
for torrent in feed.torrents:
print(torrent)
feed = await client.get_feed(magnet_only=True)
© 2023-2024 Zrekryu. Licensed under MIT License. See the LICENSE file for details.