Skip to main content

Fandom Scraper

A simple AI (span marker) powered fandom scraper.

Installation

# (recommended)
uv add fandom-scraper

# or
pip install fandom-scraper

Usage

The usage is very simple, the function requires path with so-called seeds to start scraping e.g. examples/witcher_json/witcher_1.json

[
    "Geralt of Rivia", "Triss Merigold", "Vesemir", "Leo", "Lambert", 
    "Eskel", "Alvin", "Shani", "Zoltan Chivay", "Dandelion (Jaskier)", 
    "King Foltest", "Adda the White",

    "Jacques de Aldersberg", "Azar Javed", "Professor (leader of Salamandra)", 
    ...
]

and later uses sugesions provided by an Named Entity Recognition (NER) model. The script saves the scraped pages and instructions into respective folders.

from fandom_scraper import scrape_fandom
in_path = "./examples/witcher_json"
out_path = "./examples/async_fandom"
instruct_path = "./examples/async_fandom_instruct"

wiki = "Witcher"
lang = "en"

scrape_fandom(in_path=in_path,
              out_path=out_path,
              instruct_path=instruct_path,
              n_workers=50, # n async page "fetchers"
              wiki=wiki,
              lang=lang)

See examples/async_fandom/ and examples/async_fandom_instruct/ for more examples.

In order to turn the scraped instructions into a .jsonl file that can be used by Cirilla models use:

from fandom_scraper import instructions_into_conv

instructions_into_conv('./examples/async_fandom_instruct', './examples/fandom_instruct.jsonl')

The resulting file will look like:

{"subject": "Shani", "text": [{"role": "user", "content": "What role did Shani play in the Battle of Brenna?"}, {"role": "assistant", "content": "Shani played a vital role in the Battle of Brenna in March 1268, serving in a field hospital under Milo Rusty Vanderbeck. Despite her youth, she effectively managed the demanding and gruesome conditions, providing essential medical aid to the wounded, contributing to the victory of the Northern Kingdoms."}], "data type": "conv", "source": "fandom"}
{"subject": "Shani", "text": [{"role": "user", "content": "How did Shani become the Dean of the Department of Medicine at Oxenfurt Academy?"}, {"role": "assistant", "content": "Shani, initially a medical student at Oxenfurt Academy, demonstrated her medical proficiency at a young age. She served in Milo Rusty Vanderbecks field hospital at the Battle of Brenna. Her exceptional skills and commitment to the field led to her appointment as the Dean of the Department of Medicine at Oxenfurt Academy."}], "data type": "conv", "source": "fandom"}
...

Effectiveness

For the Witcher fandom, the scraper managed to gather 7506 pages, 1494 instructions. All in all around 40MiB of pure text in around 4 hours.

Metadata

Release files for fandom-scraper 0.6.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for fandom-scraper 0.6.4
File Size Uploaded Provenance Actions
fandom_scraper-0.6.4.tar.gz 5.7 kB Without provenance Details for fandom_scraper-0.6.4.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for fandom-scraper 0.6.4
File Interpreter ABI Platform Actions
fandom_scraper-0.6.4-py3-none-any.whl Python 3 none any Details for fandom_scraper-0.6.4-py3-none-any.whl

Total release size: 12.7 kB

Release files / fandom_scraper-0.6.4.tar.gz

Download URL fandom_scraper-0.6.4.tar.gz
Size 5.7 kB
Tags Source
SHA-256 checksum
How to use checksums
67ba364b990b338f95aea87e4816e455a23e7e0ed85fb936770124c9344d948d
BLAKE2b-256 checksum
How to use checksums
6fba4e830795a72e6789bdd5c8386b7f3ed7543db8826315045f7917ce61be7e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.8.0

Release files / fandom_scraper-0.6.4-py3-none-any.whl

Download URL fandom_scraper-0.6.4-py3-none-any.whl
Size 6.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
600e5ce898d5c59298fac947f887d3fc5610882b61f5af89cc4d80f01b9fd005
BLAKE2b-256 checksum
How to use checksums
4354ce9870400d7c1ebf1f311f8ee8c9f835e93a1f513ca2986ec53cc5228074
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.8.0

Security for fandom-scraper 0.6.4

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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A 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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page