From c7ff699303e95e955ea9d7e0352e951a6a50bac9 Mon Sep 17 00:00:00 2001 From: Michael Berkowitz Date: Mon, 7 Apr 2008 19:58:08 +0000 Subject: [PATCH] -Adds Royal Historical Society translator. --- scrapers.sql | 63 +++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 62 insertions(+), 1 deletion(-) diff --git a/scrapers.sql b/scrapers.sql index fe82069cf..5fd2d5d4a 100644 --- a/scrapers.sql +++ b/scrapers.sql @@ -22,7 +22,7 @@ -- Set the following timestamp to the most recent scraper update date -REPLACE INTO version VALUES ('repository', STRFTIME('%s', '2008-04-07 19:00:00')); +REPLACE INTO version VALUES ('repository', STRFTIME('%s', '2008-04-07 21:00:00')); REPLACE INTO translators VALUES ('96b9f483-c44d-5784-cdad-ce21b984fe01', '1.0.0b4.r1', '', '2008-03-21 20:00:00', '1', '100', '4', 'Amazon.com', 'Sean Takats and Michael Berkowitz', '^https?://(?:www\.)?amazon', 'function detectWeb(doc, url) { @@ -1087,6 +1087,67 @@ REPLACE INTO translators VALUES ('88915634-1af6-c134-0171-56fd198235ed', '1.0.0b Zotero.wait(); }'); +REPLACE INTO translators VALUES ('a69deb08-47d9-46ad-afca-bc3a2499ad34', '1.0.0b4.r5', '', '2008-04-07 21:00:00', '0', '100', '4', 'Royal Historical Society', 'Michael Berkowitz', 'http://www.rhs.ac.uk/bibl/', +'function detectWeb(doc, url) { + if (doc.evaluate(''//tr/td[3][@class="bib_data"]/a[@class="bibref"]'', doc, null, XPathResult.ANY_TYPE, null).iterateNext()) { + return "multiple"; + } else if (doc.evaluate(''//a[text() = "View records in XML"]'', doc, null, XPathResult.ANY_TYPE, null).iterateNext()) { + return "book"; + } +}', +'function doWeb(doc, url) { + var books = new Array(); + if (detectWeb(doc, url) == "multiple") { + var items = new Object(); + var xpath = ''//a[@class="bibref"]''; + var results = doc.evaluate(xpath, doc, null, XPathResult.ANY_TYPE, null); + var result; + while (result = results.iterateNext()) { + items[result.href] = Zotero.Utilities.trimInternal(result.textContent); + } + items = Zotero.selectItems(items); + for (var i in items) { + books.push(i.replace(/DATABASE=[^&]+/, "DATABASE=xmlcatalo")); + } + } else { + books = [url.replace(/DATABASE=[^&]+/, "DATABASE=xmlcatalo")]; + } + for each (var link in books) { + Zotero.Utilities.HTTP.doGet(link, function(text) { + text = text.replace(/<\?[^?]+\?>/, ""); + var xml = new XML(text); + xml = xml..recordList; + + var itemtype = "book"; + if (xml..journal_title.length() != 0) itemtype = "journalArticle"; + + var item = new Zotero.Item(itemtype); + item.title = xml..title; + for (var i = 0; i < xml..author.length(); i++) { + var name = xml..author[i].toString().match(/^[^,]+,[^,]+/)[0].split(/,\s+/); + item.creators.push({lastName:name[0], firstName:name[1], creatorType:"author"}); + } + if (item.itemType == "book") { + item.place = xml..place_of_publication.toString(); + item.publisher = xml..publisher.toString(); + item.date = xml..publication_year.toString(); + } else if (item.itemType == "journalArticle") { + item.publicationTitle = xml..journal_title.toString(); + var voliss = xml..journal_number.split(":"); + Zotero.debug(voliss); + item.volume = voliss[0]; + item.issue = voliss[1]; + item.date = xml..journal_issue_year; + item.pages = xml..journal_pages; + } + + item.complete(); + }); + Zotero.done; + } + Zotero.wait(); +}'); + REPLACE INTO translators VALUES ('d921155f-0186-1684-615c-ca57682ced9b', '1.0.0b4.r1', '', '2008-04-04 20:00:00', '1', '100', '4', 'JSTOR', 'Simon Kornblith, Sean Takats and Michael Berkowitz', 'https?://[^/]*jstor\.org[^/]*/(action/(showArticle|doBasicSearch|doAdvancedSearch)|stable/)', 'function detectWeb(doc, url) { var namespace = doc.documentElement.namespaceURI;