-Adds Columbia University Press translator.
This commit is contained in:
parent
46e20f1406
commit
ab4a75c158
59
scrapers.sql
59
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-05-15 17:30:00'));
|
||||
REPLACE INTO version VALUES ('repository', STRFTIME('%s', '2008-05-15 18:30: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) {
|
||||
|
@ -1149,6 +1149,63 @@ REPLACE INTO translators VALUES ('83538f48-906f-40ef-bdb3-e94f63676307', '1.0.0b
|
|||
}, function() {Zotero.done;});
|
||||
}');
|
||||
|
||||
REPLACE INTO translators VALUES ('a75e0594-a9e8-466e-9ce8-c10560ea59fd', '1.0.0b4.r5', '', '2008-05-15 18:30:00', '0', '100', '4', 'Columbia University Press', 'Michael Berkowitz', 'http://www.cup.columbia.edu/',
|
||||
'function detectWeb(doc, url) {
|
||||
if (url.match(/book\//)) {
|
||||
return "book";
|
||||
} else if (doc.evaluate(''//p[@class="header"]/a/span[@class="_booktitle"]'', doc, null, XPathResult.ANY_TYPE, null).iterateNext()) {
|
||||
return "multiple";
|
||||
}
|
||||
}',
|
||||
'function addTag(item, tag, xpath) {
|
||||
item[tag] = Zotero.Utilities.trimInternal(doc.evaluate(xpath, doc, ns, XPathResult.ANY_TYPE, null).iterateNext().textContent);
|
||||
}
|
||||
|
||||
function doWeb(doc, url) {
|
||||
var n = doc.documentElement.namespaceURI;
|
||||
var ns = n ? function(prefix) {
|
||||
if (prefix == ''x'') return n; else return null;
|
||||
} : null;
|
||||
|
||||
var books = new Array();
|
||||
|
||||
if (detectWeb(doc, url) == "multiple") {
|
||||
var items = new Object();
|
||||
var titles = doc.evaluate(''//p[@class="header"]/a'', doc, ns, XPathResult.ANY_TYPE, null);
|
||||
var title;
|
||||
while (title = titles.iterateNext()) {
|
||||
items[title.href] = title.textContent;
|
||||
}
|
||||
items = Zotero.selectItems(items);
|
||||
for (var i in items) {
|
||||
books.push(i);
|
||||
}
|
||||
} else {
|
||||
books = [url];
|
||||
}
|
||||
Zotero.Utilities.processDocuments(books, function(doc) {
|
||||
var item = new Zotero.Item("book");
|
||||
item.title = Zotero.Utilities.trimInternal(doc.evaluate(''//h1[@id="_booktitle"]'', doc, ns, XPathResult.ANY_TYPE, null).iterateNext().textContent);
|
||||
var authors = Zotero.Utilities.trimInternal(doc.evaluate(''//p[@id="_authors"]'', doc, ns, XPathResult.ANY_TYPE, null).iterateNext().textContent);
|
||||
if (authors.match(/Edited/)) {
|
||||
authors = Zotero.Utilities.trimInternal(authors.replace("Edited by", ""));
|
||||
var autType = "editor";
|
||||
} else {
|
||||
var autType = "author";
|
||||
}
|
||||
var auts = authors.split(/,|\band\b/);
|
||||
for each (var aut in auts) {
|
||||
item.creators.push(Zotero.Utilities.cleanAuthor(aut, autType));
|
||||
}
|
||||
item.abstractNote = Zotero.Utilities.trimInternal(doc.evaluate(''//p[@id="_desc"]'', doc, ns, XPathResult.ANY_TYPE, null).iterateNext().textContent);
|
||||
item.date = Zotero.Utilities.trimInternal(doc.evaluate(''//span[@id="_publishDate"]'', doc, ns, XPathResult.ANY_TYPE, null).iterateNext().textContent);
|
||||
item.ISBN = Zotero.Utilities.trimInternal(doc.evaluate(''//span[@id="_isbn"]'', doc, ns, XPathResult.ANY_TYPE, null).iterateNext().textContent);
|
||||
item.publisher = Zotero.Utilities.trimInternal(doc.evaluate(''//span[@id="_publisher"]'', doc, ns, XPathResult.ANY_TYPE, null).iterateNext().textContent);
|
||||
item.complete();
|
||||
}, function() {Zotero.done;});
|
||||
Zotero.wait();
|
||||
}');
|
||||
|
||||
REPLACE INTO translators VALUES ('0c661209-5ec8-402b-8f18-7dec6ae37d95', '1.0.0b4.r5', '', '2008-05-15 00:30:00', '0', '100', '4', 'The Free Dictionary', 'Michael Berkowitz', 'http://(.*\.)?thefreedictionary.com/(\w+)',
|
||||
'function detectWeb(doc, url) {
|
||||
return "dictionaryEntry";
|
||||
|
|
Loading…
Reference in New Issue
Block a user