Scaffold templates: Pull URL from doc

Link URLs could lead to redirects.
This commit is contained in:
Abe Jellinek 2022-05-12 14:49:30 -07:00 committed by Dan Stillman
parent 7d3e95e050
commit 139d92054f
5 changed files with 10 additions and 5 deletions

View file

@ -57,7 +57,7 @@ async function doWeb(doc, url) {
if (items) { if (items) {
await Promise.all( await Promise.all(
Object.keys(items) Object.keys(items)
.map(url => requestDocument(url).then(doc => scrape(doc, url))) .map(url => requestDocument(url).then(scrape))
); );
} }
} }
@ -65,3 +65,8 @@ async function doWeb(doc, url) {
await scrape(doc, url); await scrape(doc, url);
} }
} }
function scrape(doc, url = doc.location.href) {
// TODO: implement or add a scrape function template
}

View file

@ -1,4 +1,4 @@
async function scrape(doc, url) { async function scrape(doc, url = doc.location.href) {
// TODO adjust the url building // TODO adjust the url building
let m = url.match(/FId=([\w\d]+)&/); let m = url.match(/FId=([\w\d]+)&/);
if (m) { if (m) {

View file

@ -1,4 +1,4 @@
async function scrape(doc, url) { async function scrape(doc, url = doc.location.href) {
let translator = Zotero.loadTranslator('web'); let translator = Zotero.loadTranslator('web');
// Embedded Metadata // Embedded Metadata
translator.setTranslator('951c027d-74ac-47d4-a107-9c3069ab7b48'); translator.setTranslator('951c027d-74ac-47d4-a107-9c3069ab7b48');

View file

@ -1,4 +1,4 @@
async function scrape(doc, url) { async function scrape(doc, url = doc.location.href) {
// TODO adjust the selector for the lines here // TODO adjust the selector for the lines here
let lines = doc.querySelectorAll('table#marcData tr'); let lines = doc.querySelectorAll('table#marcData tr');

View file

@ -1,4 +1,4 @@
async function scrape(doc, url) { async function scrape(doc, url = doc.location.href) {
let DOI = url.match(/\/(10\.[^#?]+)/)[1]; let DOI = url.match(/\/(10\.[^#?]+)/)[1];
// TODO adjust the URL here // TODO adjust the URL here
let risURL = `http://citation-needed.services.springer.com/v2/references/${DOI}?format=refman&flavour=citation`; let risURL = `http://citation-needed.services.springer.com/v2/references/${DOI}?format=refman&flavour=citation`;