zotero / translators

Zotero Translators
http://www.zotero.org/support/dev/translators
1.26k stars 750 forks source link

Translator for eLibrary.ru not working again #3284

Closed sergbolshakov closed 6 months ago

sergbolshakov commented 6 months ago

In eLibrary.ru again seems to have changed something in the clutter of tables within tables, and the translator again does not work, does not save anything except the metadata that is written in <head>. I don't know how to JavaScript, I just tried to change the code in some places so that the translator would at least save the authors and the name of the journal - it didn't work. I tried replacing the XPaths with the ones I was getting with the developer tools in the browser on the eLibrary article page. My attempts to change the code of the current scrape function:

// XPath:
// /html/body/table/tbody/tr/td/table[1]/tbody/tr/td[2] - rightPart
// /html/body/table/tbody/tr/td/table[1]/tbody/tr/td[2]/table/tbody/tr[2]/td[1] - centralColumn
// /html/body/table/tbody/tr/td/table[1]/tbody/tr/td[2]/table/tbody/tr[2]/td[1]/div[2] - datablock
// /html/body/table/tbody/tr/td/table[1]/tbody/tr/td[2]/table/tbody/tr[2]/td[1]/div[2]/table[1]/tbody/tr/td[2] - authors
// /html/body/table/tbody/tr/td/table[1]/tbody/tr/td[2]/table/tbody/tr[2]/td[1]/div[2]/table[1]/tbody/tr/td[2]/div[1]/span/b/font - firstAuthor
// /html/body/table/tbody/tr/td/table[1]/tbody/tr/td[2]/table/tbody/tr[2]/td[1]/div[2]/table[1]/tbody/tr/td[2]/div[2]/span/b/font - secondAuthor

var rightPart = doc.getElementById("leftcol").nextSibling;
// var centralColumn = ZU.xpath(rightPart, './table/tbody/tr[2]/td[@align="left"]'); // original
var centralColumn = ZU.xpath(rightPart, './table/tbody/tr[2]/td[1]'); // my try
// var datablock = ZU.xpath(centralColumn, './div[1]'); // original
var datablock = ZU.xpath(centralColumn, './div[2]'); // my try

// var authors = ZU.xpath(datablock, './/table[1]//b'); // original
// var authors = ZU.xpath(datablock, './/table[1]/tbody/tr/td[2]/div/span/b/font'); // my try
var authors = ZU.xpath(datablock, './/table[1]//font'); // my 2nd try

and

// XPath:
// /html/body/table/tbody/tr/td/table[1]/tbody/tr/td[2] - rightPart
// /html/body/table/tbody/tr/td/table[1]/tbody/tr/td[2]/table/tbody/tr[2]/td[1] - centralColumn
// /html/body/table/tbody/tr/td/table[1]/tbody/tr/td[2]/table/tbody/tr[2]/td[1]/div[2] - datablock
// /html/body/table/tbody/tr/td/table[1]/tbody/tr/td[2]/table/tbody/tr[2]/td[1]/div[2]/table[3]/tbody/tr[2]/td[2] - journalBlock
// /html/body/table/tbody/tr/td/table[1]/tbody/tr/td[2]/table/tbody/tr[2]/td[1]/div[2]/table[3]/tbody/tr[2]/td[2]/a - publicationTitle

// var journalBlock = ZU.xpath(datablock, './table/tbody[tr[1]/td/font[contains(text(), "ЖУРНАЛ:")]]/tr[2]/td[2]'); // original
var journalBlock = ZU.xpath(datablock, './table[3]/tbody/tr[2]/td[2]'); // my try
// if (!item.publicationTitle) item.publicationTitle = ZU.xpathText(journalBlock, ".//a[1]"); // original
if (!item.publicationTitle) item.publicationTitle = ZU.xpathText(journalBlock, "./a"); // my try
item.publicationTitle = fixCasing(item.publicationTitle);

What am I doing wrong? The horrible eLibrary remains one of the main and largest sources of literature, and saving records now has to be done manually, for volumes larger than a dozen it is extremely exhausting. Maybe colleagues who were previously involved in improving this translator will respond and help? @advoropaev, @zuphilip, @i3v?

advoropaev commented 6 months ago

Hello, I did a quick fix, consider it, please, I have opened a pull request as well.

eLibrary.ru.js.zip

sergbolshakov commented 6 months ago

@advoropaev, thank you very much, everything works as it should! (Turns out I didn't have the Zotero connector updated.)