Skip to content

Commit

Permalink
save judgment pdf as attachment when available
Browse files Browse the repository at this point in the history
  • Loading branch information
timcowlishaw committed Dec 11, 2023
1 parent 4bffc4e commit 36b3cee
Showing 1 changed file with 21 additions and 3 deletions.
24 changes: 21 additions & 3 deletions National Archives (UK) Find Case Law.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"inRepository": true,
"translatorType": 4,
"browserSupport": "gcsibv",
"lastUpdated": "2023-12-11 14:59:32"
"lastUpdated": "2023-12-11 17:04:08"
}

/*
Expand Down Expand Up @@ -86,7 +86,7 @@ function scrape(doc, url) {
new Array(xpath('//akn:judge/@refersTo')).forEach(function (href) {
if (href !== null) {
const id = href.replace("#", "");
item.creators.pop({
item.creators.push({
lastName: xpath(`//akn:TLCPerson[@eId='${id}']/@showAs`),
creatorType: "author",
fieldMode: 1
Expand All @@ -95,6 +95,19 @@ function scrape(doc, url) {
});
const ncn = xpath("//uk:cite");
item.notes.push({ note: `Neutral Citation Number: ${ncn}` });
ZU.doGet(item.uri, function(text) {

Check warning on line 98 in National Archives (UK) Find Case Law.js

View workflow job for this annotation

GitHub Actions / Lint, Check, Test

Missing space before function parentheses
const parser = new DOMParser();
const htmlDoc = parser.parseFromString(text, "text/html");
const downloadButton = htmlDoc.querySelector(".judgment-toolbar-buttons__option--pdf")

Check failure on line 101 in National Archives (UK) Find Case Law.js

View workflow job for this annotation

GitHub Actions / Lint, Check, Test

Missing semicolon
const pdfURL = downloadButton && downloadButton.getAttribute("href");

Check failure on line 102 in National Archives (UK) Find Case Law.js

View workflow job for this annotation

GitHub Actions / Lint, Check, Test

Trailing spaces not allowed
if (pdfURL) {
item.attachments.push({
url: "https://caselaw.nationalarchives.gov.uk" + pdfURL,
title: "Full Text PDF",
mimeType: "application/pdf"
});
}
});
item.complete();
});
}
Expand Down Expand Up @@ -138,7 +151,12 @@ var testCases = [
"creators": [],
"dateDecided": "2021-04-20",
"court": "EWCA-Civil",
"attachments": [],
"attachments": [
{
"title": "Full Text PDF",
"mimeType": "application/pdf"
}
],
"tags": [],
"notes": [
{
Expand Down

0 comments on commit 36b3cee

Please sign in to comment.