nyaasi-scraper is an asynchronous Python library for scraping nyaa.si and sukebei.nyaa.si, utilizing BeautifulSoup4 and httpx.
Project description
nyaasi-scraper
nyaasi-scraper is an asynchronous Python library for scraping nyaa.si and sukebei.nyaa.si, utilizing BeautifulSoup4 and httpx.
Installation
Installing through pip.
pip install nyaasi-scraper
Usage
Initializing client with site
By default, the site is nyaa.si (work-safe site).
from nyaascraper import NyaaClient, SITE
# Work-safe site.
client = NyaaClient(SITE.FUN)
# Non-work-safe site.
client = NyaaClient(SITE.FAP)
Changing Site
You can change the site of the client dynamically.
from nyaascraper import SITE
client.site = SITE.FUN
Searching Torrents
Search with Query
from nyaascraper.models import SearchResult
result: SearchResult = await client.search(query="your query...")
print(result)
# Iterate over torrents.
for torrent in result.torrents:
print(torrent)
Search with Filter
from nyaascraper.models import SearchResult
from nyaascraper import Filter
result: SearchResult = await client.search(filter_=Filter.TRUSTED_ONLY)
print(result)
See help(Filter)
for more.
Search with Category
from nyaascraper.enums import FunCategory, FapCategory
from nyaascraper.models import SearchResult
# Work-safe category.
result: SearchResult = await client.search(category=FunCategory.ANIME)
print(result)
# Work-safe subcategory search.
result: SearchResult = await client.search(category=FunCategory.ANIME__ENGLISH_TRANSLATED)
print(result)
# Non-work-safe category.
result: SearchResult = await client.search(category=FapCategory.ART)
print(result)
# Non-work-safe subcategory search.
result: SearchResult = await client.search(category=FunCategory.ART__MANGA)
print(result)
See help(FunCategory)
and help(FapCategory)
for more.
Search Sorting
from nyaascraper.enums import SortBy, SortOrder
from nyaascraper.models import SearchResult
result: SearchResult = await client.search(sort_by=SortBy.DATE, sort_order=SortOrder.DESCENDING)
print(result)
See help(SortBy)
and help(SortOrder)
for more.
Search by Page
from nyaascraper.models import SearchResult
result: SearchResult = await client.search(page=2)
print(result)
Getting Torrent Information
from nyaascraper.models import SearchResult, TorrentInfo
result: SearchResult = await client.search()
# Select View-ID of first torrent from the search result.
view_id: int = result.torrents[0].view_id
torrent_info: TorrentInfo = await client.get_torrent_info(view_id)
print(torrent_info)
License
Licensed under MIT License. See the LICENSE file for details.
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
nyaasi_scraper-1.0.0.tar.gz
(10.0 kB
view hashes)
Built Distribution
Close
Hashes for nyaasi_scraper-1.0.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 623048bcf82a7a084610953712a7bccf228b7a52b0d027a8386f1e3947980f52 |
|
MD5 | c211f89343a592f275fafca47c45c3c9 |
|
BLAKE2b-256 | bd00f21677ea894f71727991f0f92bcc31f747068f3475ac02c2529e1d639663 |