Skip to content

Instantly share code, notes, and snippets.

@tkfu
tkfu / monsters2cards.rb
Created February 2, 2018 03:55
A quickie script to turn the monsters scraped with [this script](https://gist.github.com/tkfu/bc5dc2c6cee4d1e582a3d369c3077bb5) into cards you can use [here](https://crobi.github.io/rpg-cards/generator/generate.html)
# Probably only works on Ruby 2.5.0
require 'json'
def create_monster mon
cont = []
cont.append("subtitle | #{mon['meta']}")
cont.append("rule")
cont.append("property | Armor class | #{mon['Armor Class']}")
cont.append("property | Hit points | #{mon['Hit Points']}")
@tkfu
tkfu / beyond-scraper.rb
Last active November 23, 2023 22:02
Script to scrape SRD-licensed monster data from DnD Beyond. Brittle, simple, but it works as of the posting of this gist.
require 'json'
require 'nokogiri'
require 'open-uri'
require 'rails-html-sanitizer'
def get_monster_list
monster_urls = []
firstpage = Nokogiri::HTML(open("https://www.dndbeyond.com/monsters?filter-search=&filter-source=1&filter-type=0&page=1"))
num_pages = firstpage.xpath('//li[@class="b-pagination-item"]')[firstpage.xpath('//li[@class="b-pagination-item"]').length - 2].text.to_i
puts "Found #{num_pages} pages..."
[
{
"title": "Aboleth",
"icon": "imp-laugh",
"contents": [
"subtitle | Large aberration, lawful evil",
"rule",
"property | Armor class | 17 (Natural Armor)",
"property | Hit points | 135 (18d10 + 36)",
"property | Speed | 10 ft., swim 40 ft. ",
@tkfu
tkfu / srd_5e_monsters.json
Last active March 23, 2024 15:45
A JSON file with all the D&D 5e SRD monster data
[
{
"name": "Aboleth",
"meta": "Large aberration, lawful evil",
"Armor Class": "17 (Natural Armor)",
"Hit Points": "135 (18d10 + 36)",
"Speed": "10 ft., swim 40 ft. ",
"STR": "21",
"STR_mod": "(+5)",
"DEX": "9",