Skip to content
Permalink
Browse files

Update

  • Loading branch information...
zuphilip committed Jun 2, 2015
1 parent ca64134 commit 6656fa41cce4100f928dc32b300dba1bf819efa2
@@ -9,7 +9,7 @@
"inRepository": true,
"translatorType": 4,
"browserSupport": "gcs",
"lastUpdated": "2013-02-28 15:02:29"
"lastUpdated": "2015-06-02 06:04:02"
}

function detectWeb(doc, url) {
@@ -46,31 +46,69 @@ function doWeb(doc, url) {
}


function scrape (doc, url){
var data = new Object();
var rows = doc.evaluate('//div[@class="fichaISBN"]/table/tbody/tr', doc, null, XPathResult.ANY_TYPE, null);
var next_row;
while (next_row = rows.iterateNext()) {
var heading = doc.evaluate('./th', next_row, null, XPathResult.ANY_TYPE, null).iterateNext().textContent;
var value = doc.evaluate('./td', next_row, null, XPathResult.ANY_TYPE, null).iterateNext().textContent;
data[heading.replace(/\W/g, "")] = value;
}
var isbn = Zotero.Utilities.trimInternal(doc.evaluate('//span[@class="cabTitulo"]/strong', doc, null, XPathResult.ANY_TYPE, null).iterateNext().textContent);
var item = new Zotero.Item("book");
item.ISBN = isbn;
item.title = Zotero.Utilities.trimInternal(data['Ttulo']);
item.title= item.title.replace(/\s+:/, ":");
author = data['Autores'];
if (author) {
var authors = author.match(/\b.*,\s+\w+[^([]/g);
for (let aut of authors) {
item.creators.push(Zotero.Utilities.cleanAuthor(Zotero.Utilities.trimInternal(aut), "author", true));
}
function scrape (doc, url){
var data = new Object();
var rows = doc.evaluate('//div[@class="fichaISBN"]/table/tbody/tr', doc, null, XPathResult.ANY_TYPE, null);
var next_row;
while (next_row = rows.iterateNext()) {
var heading = doc.evaluate('./th', next_row, null, XPathResult.ANY_TYPE, null).iterateNext().textContent;
var value = doc.evaluate('./td', next_row, null, XPathResult.ANY_TYPE, null).iterateNext().textContent;
data[heading.replace(/\W/g, "")] = value;
}
var isbn = Zotero.Utilities.trimInternal(doc.evaluate('//span[@class="cabTitulo"]/strong', doc, null, XPathResult.ANY_TYPE, null).iterateNext().textContent);
var item = new Zotero.Item("book");
item.ISBN = isbn;
item.title = Zotero.Utilities.trimInternal(data['Ttulo']);
item.title= item.title.replace(/\s+:/, ":");
author = data['Autores'];
if (author) {
var authors = author.match(/\b.*,\s+\w+[^([]/g);
for (var i=0; i<authors.length; i++) {
var aut = Zotero.Utilities.trimInternal(authors[i]);
item.creators.push(Zotero.Utilities.cleanAuthor(aut, "author", true));
}
if (data['Publicacin']) item.publisher = Zotero.Utilities.trimInternal(data['Publicacin']);
if (data['FechaEdicin']) item.date = Zotero.Utilities.trimInternal(data['FechaEdicin']);
item.complete();
}
if (data['Publicacin']) item.publisher = Zotero.Utilities.trimInternal(data['Publicacin']);
if (data['FechaEdicin']) item.date = Zotero.Utilities.trimInternal(data['FechaEdicin']);
item.complete();
}

/** BEGIN TEST CASES **/
var testCases = []
var testCases = [
{
"type": "web",
"url": "http://www.mcu.es/webISBN/tituloDetalle.do?sidTitul=292802&action=busquedaInicial&noValidating=true&POS=0&MAX=50&TOTAL=0&prev_layout=busquedaisbn&layout=busquedaisbn&language=es",
"items": [
{
"itemType": "book",
"title": "La actitud intencional",
"creators": [
{
"firstName": "Daniel",
"lastName": "Dennett",
"creatorType": "author"
},
{
"firstName": "Daniel",
"lastName": "Dennett",
"creatorType": "author"
},
{
"firstName": "Gabriela",
"lastName": "Ventureira",
"creatorType": "author"
}
],
"date": "03/1991",
"ISBN": "9788474323955",
"libraryCatalog": "Agencia del ISBN",
"publisher": "GEDISA",
"attachments": [],
"tags": [],
"notes": [],
"seeAlso": []
}
]
}
]
/** END TEST CASES **/
@@ -1,14 +1,15 @@
{
"translatorID":"0dda3f89-15de-4479-987f-cc13f1ba7999",
"translatorType":4,
"label":"Ancestry.com US Federal Census",
"creator":"Elena Razlogova",
"target":"^https?://search.ancestry.com/(.*)usfedcen|1890orgcen|1910uscenindex",
"minVersion":"1.0.0b4.r1",
"maxVersion":"",
"priority":100,
"inRepository":true,
"lastUpdated":"2011-01-11 04:31:00"
"translatorID": "0dda3f89-15de-4479-987f-cc13f1ba7999",
"label": "Ancestry.com US Federal Census",
"creator": "Elena Razlogova",
"target": "^https?://search.ancestry.com/(.*)usfedcen|1890orgcen|1910uscenindex",
"minVersion": "1.0.0b4.r1",
"maxVersion": "",
"priority": 100,
"inRepository": true,
"translatorType": 4,
"browserSupport": "g",
"lastUpdated": "2015-06-02 10:57:09"
}

function detectWeb(doc, url) {
@@ -18,7 +19,7 @@ function detectWeb(doc, url) {
} : null;

var result = doc.evaluate('//div[@class="g_container"]/div[@class="g_panelWrap"]/div[@class="g_panelCore"]/div[@class="s_container"]/div[@class="p_rsltList"]', doc, nsResolver,
XPathResult.ANY_TYPE, null).iterateNext();
XPathResult.ANY_TYPE, null).iterateNext();

var rows = doc.evaluate('//div[@class="g_container"]/div[@class="g_panelWrap"]/div[@class="g_panelCore"]/div[@class="s_container"]/div[@class="p_rsltList"]/table/tbody/tr[@class="tblrow record"]',
doc, nsResolver, XPathResult.ANY_TYPE, null);
@@ -70,7 +71,8 @@ function scrape(doc) {
info = info.toString();
var data = new Array();
var parts = info.split(/[?&]/);
for (let part of parts) {
for (var i=0; i<parts.length; i++) {
var part = parts[i];
var index = part.indexOf("=");
if(index !== -1) {
data[part.substr(0, index)] = part.substr(index+1);
@@ -103,9 +105,9 @@ function scrape(doc) {
var censusNo = "";
var censusNos = new Array("1790", "First", "1800", "Second", "1810", "Third", "1820", "Fourth", "1830", "Fifth", "1840", "Sixth", "1850", "Seventh", "1860", "Eighth", "1870", "Ninth",
"1880", "Tenth", "1890", "Eleventh", "1900", "Twelfth", "1910", "Thirteenth", "1920", "Fourteenth", "1930", "Fifteenth")
for(var i in censusNos) {
if(censusYear == 1) { censusNo = censusNos[i] };
if(censusNos[i] == year) { censusYear = 1 } else {censusYear= 0 };
for(var j in censusNos) {
if(censusYear == 1) { censusNo = censusNos[j] };
if(censusNos[j] == year) { censusYear = 1 } else {censusYear= 0 };
}

//begin adding item
@@ -9,7 +9,7 @@
"inRepository": true,
"translatorType": 4,
"browserSupport": "gcsibv",
"lastUpdated": "2012-03-03 23:29:34"
"lastUpdated": "2015-06-02 05:58:49"
}

function detectWeb(doc, url) {
@@ -57,7 +57,8 @@ function doWeb(doc, url) {
for (var tag in metaTags) {
if (tag == "DC.creator") {
var authors = data['DC.creator'].split(";");
for (let aut of authors) {
for (var i=0; i<authors.length; i++) {
var aut = authors[i];
aut = aut.replace(/^([^,]+),\s+(.*)$/, "$2 $1");
item.creators.push(Zotero.Utilities.cleanAuthor(aut, "author"));
}
@@ -9,7 +9,7 @@
"inRepository": true,
"translatorType": 4,
"browserSupport": "gcsibv",
"lastUpdated": "2014-04-28 19:32:32"
"lastUpdated": "2015-06-02 08:32:10"
}

function detectWeb(doc, url) {
@@ -43,7 +43,7 @@ function scrape(doc, url) {
var content = doc.evaluate('//div[@id="description"]/ul/li', doc, null, XPathResult.ANY_TYPE, null);
var xPathCount = doc.evaluate('count (//div[@id="description"]/ul/li)', doc, null, XPathResult.ANY_TYPE, null);

for (i=0; i<xPathCount.numberValue; i++) {
for (var i=0; i<xPathCount.numberValue; i++) {
contents = content.iterateNext().textContent.split(": ");
if (contents.length>1){
fieldTitle = contents[0].replace(/\s*/g, '');
@@ -56,7 +56,8 @@ function scrape(doc, url) {
if (authors.match(/\w/)) {
authors = authors.replace(/^\s*by/, "");
multiAuthors = authors.split(";");
for (let aut of multiAuthors) {
for (var j=0; j<multiAuthors.length; j++) {
var aut = multiAuthors[j];
newItem.creators.push(Zotero.Utilities.cleanAuthor(aut, "author", aut.match(/,/)));
}
}
@@ -9,7 +9,7 @@
"inRepository": true,
"translatorType": 4,
"browserSupport": "gcsibv",
"lastUpdated": "2013-01-23 12:41:08"
"lastUpdated": "2015-06-02 10:52:41"
}

function detectWeb(doc, url) {
@@ -67,7 +67,8 @@ function doWeb(doc, url) {
var splitRe = new RegExp(title);
var authors = data.split(splitRe)[0].replace(/\([^)]+\)/, "").split(/(,|and)\s+/);
Zotero.debug(authors);
for (let aut of authors) {
for (var i=0; i<authors.length; i++) {
var aut = authors[i];
if (aut.match(/\w/) && (aut != "and")) {
item.creators.push(Zotero.Utilities.cleanAuthor(aut, "reviewedAuthor"));
}
@@ -9,7 +9,7 @@
"inRepository": true,
"translatorType": 4,
"browserSupport": "gcsibv",
"lastUpdated": "2015-06-01 21:47:01"
"lastUpdated": "2015-06-02 10:55:49"
}

function detectWeb(doc, url) {
@@ -55,11 +55,12 @@ function doWeb(doc, url) {

function scrape(doc, url) {
var item = new Zotero.Item("book");
item.title = Zotero.Utilities.trimInternal(ZU.xpathText(doc, '//h1[@id="_booktitle"]'));Z.debug(title);
item.title = Zotero.Utilities.trimInternal(ZU.xpathText(doc, '//h1[@id="_booktitle"]'));
var authors = Zotero.Utilities.trimInternal(ZU.xpathText(doc, '//p[@id="_authors"]'));
//we parse the author string - first assign roles and then split multiple authors in those groups.
var auts = authors.split(/;/);
for (let aut of auts) {
for (var i=0; i<auts.length; i++) {
var aut = auts[i];
if (aut.match(/Edited/)) {
var autType = "editor";
aut = aut.replace(/Edited (by)?/, "");
@@ -70,7 +71,8 @@ function scrape(doc, url) {
var autType = "author";
}
aut = aut.split(/\band\b|,/);
for (let aut2 of aut) {
for (var j=0; j<aut.length; j++) {
var aut2 = aut[j];
item.creators.push(Zotero.Utilities.cleanAuthor(aut2, autType));
}
}
Oops, something went wrong.

0 comments on commit 6656fa4

Please sign in to comment.
You can’t perform that action at this time.