Skip to content

distributive/NetrunnerScraper

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 

Repository files navigation

NetrunnerScraper

A basic Python scraper for NetrunnerDB cards. Works with NetrunnerDB's v2 API and tested in Python 3.9.5.

How to use

python scraper.py

How to modify the output

By default it searches for all cards in the Startup format at the time of writing (System Gateway, System Update 21, Ashes, Midnight Sun Booster Pack). You can change which cards are filtered by changing this section of code:

# Data to include/exclude
startup_pack_codes = ["sg", "su21", "df", "ur", "msbp"]
non_startup_codes = ["30076", "30077"]

# Filter by the above parameters, then format into a single string
startup_cards = filter(lambda c : c["pack_code"] in startup_pack_codes and c["code"] not in non_startup_codes, cards)
formatted = "\n".join(map(format, startup_cards))

You can filter by any fields cards have (note that not every card has every possible field, so you may need to perform additional checks for things like advancement cost or trash cost). See the API itself for the fields cards can have.

You can add, remove, and reorder the output fields by changing this line:

# The fields to include from each card
fields = ["title", "text", "cost", "strength", "trash_cost"]

The script checks if each card has each specified field, so you don't need to perform additional checks.

You can change the name of the output file by changing the file parameter at the top of the script.

How to import into Excel

Once you have the formatted CSV file, you can import it into Excel by opening a new Excel file and going to the Data tab:

The Data tab of Excel

Click of From Text/CSV and choose your outputted card data. You'll need to set the delimiter to match that of the file:

The CSV import window

By default, each field in the output is separated by a pipe (|). CSVs are normally comma separated, but since cards can contain commas in their text a pipe is used instead. If you want to change this for any reason (e.g. a future card has a pipe in its text) you can change the delimiter parameter at the top of the script.

About

A basic Python scraper for NetrunnerDB cards

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages