Created
April 8, 2022 12:32
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
---<%* | |
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 %>" | |
--- |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Further development will be continued here: https://github.com/basilioss/obsidian-scrapers