-Fixes APA PyscNET translator.
This commit is contained in:
parent
a3c5308b8b
commit
31cb75c2b7
51
scrapers.sql
51
scrapers.sql
|
@ -4872,7 +4872,7 @@ REPLACE INTO translators VALUES ('252c6a50-0900-41c5-a66b-ec456137c43c', '1.0.0b
|
|||
}, function() {Zotero.done;});
|
||||
}');
|
||||
|
||||
REPLACE INTO translators VALUES ('1e1e35be-6264-45a0-ad2e-7212040eb984', '1.0.0b4.r5', '', '2008-05-05 07:45:00', '0', '100', '4', 'APA PsycNET', 'Michael Berkowitz', 'http://psycnet\.apa\.org/',
|
||||
REPLACE INTO translators VALUES ('1e1e35be-6264-45a0-ad2e-7212040eb984', '1.0.0b4.r5', '', '2008-06-23 11:17:50', '0', '100', '4', 'APA PsycNET', 'Michael Berkowitz', 'http://psycnet\.apa\.org/',
|
||||
'function detectWeb(doc, url) {
|
||||
if (url.match(/search\.searchResults/)) {
|
||||
return "multiple";
|
||||
|
@ -4880,7 +4880,11 @@ REPLACE INTO translators VALUES ('1e1e35be-6264-45a0-ad2e-7212040eb984', '1.0.0b
|
|||
return "journalArticle";
|
||||
}
|
||||
}',
|
||||
'function doWeb(doc, url) {
|
||||
'function associateXPath(xpath, doc, ns) {
|
||||
return Zotero.Utilities.trimInternal(doc.evaluate(xpath, doc, ns, XPathResult.ANY_TYPE, null).iterateNext().textContent);
|
||||
}
|
||||
|
||||
function doWeb(doc, url) {
|
||||
var namespace = doc.documentElement.namespaceURI;
|
||||
var nsResolver = namespace ? function(prefix) {
|
||||
if (prefix == ''x'') return namespace; else return null;
|
||||
|
@ -4903,20 +4907,37 @@ REPLACE INTO translators VALUES ('1e1e35be-6264-45a0-ad2e-7212040eb984', '1.0.0b
|
|||
}
|
||||
Zotero.Utilities.processDocuments(arts, function(doc) {
|
||||
var newurl = doc.location.href;
|
||||
var id = doc.evaluate(''//input[@name="id"]'', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().value;
|
||||
var lstSelectedUIDs = doc.evaluate(''//input[@name="lstUIDs"][@id="srhLstUIDs"]'', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().value;
|
||||
var get = ''http://psycnet.apa.org/index.cfm?fa=search.export&id='' + id + ''&lstSelectedUIDs='' + lstSelectedUIDs + ''&lstUIDs=&records=selected&displayFormat=&exportFormat=referenceSoftware&printDoc=0'';
|
||||
Zotero.Utilities.HTTP.doGet(get, function(text) {
|
||||
var translator = Zotero.loadTranslator("import");
|
||||
translator.setTranslator("32d59d2d-b65a-4da4-b0a3-bdd3cfb979e7");
|
||||
translator.setString(text);
|
||||
translator.setHandler("itemDone", function(obj, item) {
|
||||
item.url = newurl;
|
||||
item.attachments = [{url:newurl, title:"APA PsycNET Snapshot", mimeType:"text/html"}];
|
||||
item.complete();
|
||||
if (doc.evaluate(''//input[@name="id"]'', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()) {
|
||||
var id = doc.evaluate(''//input[@name="id"]'', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().value;
|
||||
var lstSelectedUIDs = doc.evaluate(''//input[@name="lstUIDs"][@id="srhLstUIDs"]'', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().value;
|
||||
var get = ''http://psycnet.apa.org/index.cfm?fa=search.export&id='' + id + ''&lstSelectedUIDs='' + lstSelectedUIDs + ''&lstUIDs=&records=selected&displayFormat=&exportFormat=referenceSoftware&printDoc=0'';
|
||||
Zotero.Utilities.HTTP.doGet(get, function(text) {
|
||||
var translator = Zotero.loadTranslator("import");
|
||||
translator.setTranslator("32d59d2d-b65a-4da4-b0a3-bdd3cfb979e7");
|
||||
translator.setString(text);
|
||||
translator.setHandler("itemDone", function(obj, item) {
|
||||
item.url = newurl;
|
||||
item.attachments = [{url:newurl, title:"APA PsycNET Snapshot", mimeType:"text/html"}];
|
||||
item.complete();
|
||||
});
|
||||
translator.translate();
|
||||
});
|
||||
translator.translate();
|
||||
});
|
||||
} else {
|
||||
var item = new Zotero.Item("journalArticle");
|
||||
item.title = associateXPath(''//div[@id="rdcTitle"]'', doc, nsResolver);
|
||||
var authors = associateXPath(''//div[@id="rdcAuthors"]'', doc, nsResolver).split(/;\s+/);
|
||||
for each (var aut in authors) {
|
||||
item.creators.push(Zotero.Utilities.cleanAuthor(aut, "author", true));
|
||||
}
|
||||
var voliss = associateXPath(''//div[@id="rdcSource"]'', doc, nsResolver).match(/^([^\.]+)\.\s+(\d+\s+\w+)\s+Vol\s+(\d+)\((\d+)\)\s+(.*)$/);
|
||||
item.publicationTitle = voliss[1];
|
||||
item.date = voliss[2];
|
||||
item.volume = voliss[3];
|
||||
item.issue = voliss[4];
|
||||
item.pages = voliss[5];
|
||||
item.abstractNote = associateXPath(''//div[@id="rdRecord"]/div[@class="rdRecordSection"][2]'', doc, nsResolver);
|
||||
item.complete();
|
||||
}
|
||||
}, function() {Zotero.done;});
|
||||
Zotero.wait();
|
||||
}');
|
||||
|
|
Loading…
Reference in New Issue
Block a user