Skip to content

Instantly share code, notes, and snippets.

@basilioss
Created April 8, 2022 12:32
Show Gist options
  • Save basilioss/62adab009eeff3b9e043d88ccb74ef82 to your computer and use it in GitHub Desktop.
Save basilioss/62adab009eeff3b9e043d88ccb74ef82 to your computer and use it in GitHub Desktop.
This is an Obsidian Templater script that generates frontmatter for literature notes from Goodreads link
---<%*
let url = await tp.system.clipboard()
let page = await tp.obsidian.request({url})
let p = new DOMParser()
let doc = p.parseFromString(page, "text/html")
let $ = s => doc.querySelector(s)
let $A = s => doc.querySelectorAll(s)
%>
title: "<% $("h1[id='bookTitle']").innerHTML.trim() %>"
authors: [<%* let authors = $A("span[itemprop=name]")
var keys = Array.from(authors, authors => authors.textContent)
tR += keys.join(', ') %>]
isbn: <% $("meta[property='books:isbn']").content %>
genres: [<%* let genres = $A("a[class='actionLinkLite bookPageGenreLink']")
var keys = Array.from(genres, genres => genres.textContent.toLowerCase())
tR += keys.join(', ') %>]
cover: "<% $("img[id='coverImage']").src %>"
---
@basilioss
Copy link
Author

basilioss commented Apr 8, 2022

@AdamBuchweitz
Copy link

Thanks for this! 👏 I expanded my version to also get the publication date.

@basilioss
Copy link
Author

@AdamBuchweitz Thanks for sharing!

@AdamBuchweitz
Copy link

Happy to! I just updated mine again to rename the file to the titled of the book, shortened to avoid non-word characters like colons.

@basilioss
Copy link
Author

Further development will be continued here: https://github.com/basilioss/obsidian-scrapers

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment