From bae0a37d39c2a5392e555b3e11e931bea8fc7e13 Mon Sep 17 00:00:00 2001 From: Michael Berkowitz Date: Fri, 20 Jun 2008 14:03:14 +0000 Subject: [PATCH] -Adds two more of Adam's translators. --- scrapers.sql | 239 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 239 insertions(+) diff --git a/scrapers.sql b/scrapers.sql index 8e0f8d6ed..9fe446357 100644 --- a/scrapers.sql +++ b/scrapers.sql @@ -1091,6 +1091,245 @@ REPLACE INTO translators VALUES ('88915634-1af6-c134-0171-56fd198235ed', '1.0.0b Zotero.wait(); }'); +REPLACE INTO translators VALUES ('a7c8b759-6f8a-4875-9d6e-cc0a99fe8f43', '1.0.0b4.r5', '', '2008-06-20 09:39:46', '0', '100', '4', 'Canadian Letters and Images', 'Adam Crymble', 'http://(www.)?canadianletters.ca/', +'function detectWeb(doc, url) { + if (doc.location.href.match("results")) { + return "multiple"; + } else if (doc.location.href.match("letters.php")) { + return "document"; + } else if (doc.location.href.match("template")) { + return "artwork"; + } + +}', +'//Translator for Canadian Letters and Images. Code by Adam Crymble + + +function scrape(doc, url) { + + var namespace = doc.documentElement.namespaceURI; + var nsResolver = namespace ? function(prefix) { + if (prefix == ''x'') return namespace; else return null; + } : null; + + var dataTags = new Object(); + + var mediaType = (detectWeb(doc, url)); + if (mediaType == "document") { + var newItem = new Zotero.Item("letter"); + var title2; + + //title + if (doc.evaluate(''//h3'', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()) { + newItem.title = doc.evaluate(''//h3'', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent; + } else { + newItem.title = doc.title; + } + + //letter, diary, memoir, personal item + if (doc.evaluate(''//div[@id="collectionCategory_letters"]'', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()) { + + var xPathType = doc.evaluate(''//div[@id="collectionCategory_letters"]'', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent; + newItem.type = xPathType; + } + + //gets date, to and from + if (doc.evaluate(''//div[@class="letterInfo_label"]'', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()) { + var xPathHeaders = doc.evaluate(''//div[@class="letterInfo_label"]'', doc, nsResolver, XPathResult.ANY_TYPE, null); + var xPathContent = doc.evaluate(''//div[@class="letterInfo_title"]'', doc, nsResolver, XPathResult.ANY_TYPE, null); + var xPathCount = doc.evaluate(''count (//div[@class="letterInfo_label"])'', doc, nsResolver, XPathResult.ANY_TYPE, null); + + for (i=0; i