Skip to content

Commit fc2a1ca

Browse files
ajamtliAbeJellinek
andauthored
Amazon: Update for new layout and updating tests (zotero#2942)
Co-authored-by: Abe Jellinek <[email protected]>
1 parent 675350c commit fc2a1ca

File tree

1 file changed

+32
-32
lines changed

1 file changed

+32
-32
lines changed

Amazon.js

+32-32
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"inRepository": true,
1010
"translatorType": 4,
1111
"browserSupport": "gcsibv",
12-
"lastUpdated": "2021-06-24 16:06:30"
12+
"lastUpdated": "2022-12-15 05:18:20"
1313
}
1414

1515
function detectWeb(doc, _url) {
@@ -312,8 +312,10 @@ function scrape(doc, url) {
312312
item.abstractNote = abstractNode.textContent.trim();
313313
}
314314
}
315+
} else {
316+
item.abstractNote = text(doc, '#bookDescription_feature_div .a-expander-content');
315317
}
316-
318+
317319
// Extract info into an array
318320
var info = {},
319321
els = ZU.xpath(doc, '//div[@class="content"]/ul/li[b]');
@@ -326,21 +328,13 @@ function scrape(doc, url) {
326328
}
327329
}
328330
}
329-
if (!els.length) {
330-
// New design encountered 06/30/2013
331-
els = ZU.xpath(doc, '//tr[td[@class="a-span3"]][td[@class="a-span9"]]');
332-
for (let i = 0; i < els.length; i++) {
333-
let el = els[i],
334-
key = ZU.xpathText(el, 'td[@class="a-span3"]'),
335-
value = ZU.xpathText(el, 'td[@class="a-span9"]');
336-
if (key && value) {
337-
info[key.trim().toLowerCase()] = value.trim();
338-
}
339-
}
340-
}
341331
if (!els.length) {
342332
// New design encountered 08/31/2020
343333
els = doc.querySelectorAll('ul.detail-bullet-list li');
334+
if (!els.length) {
335+
// New design encountered 2022-11-20
336+
els = doc.querySelectorAll('#detailBullets_feature_div ul > li span');
337+
}
344338
for (let el of els) {
345339
let key = text(el, '.a-list-item span:first-child');
346340
let value = text(el, '.a-list-item span:nth-child(2)');
@@ -354,12 +348,23 @@ function scrape(doc, url) {
354348
}
355349
}
356350
}
357-
351+
if (!els.length) {
352+
// New design encountered 06/30/2013
353+
els = ZU.xpath(doc, '//tr[td[@class="a-span3"]][td[@class="a-span9"]]');
354+
for (let i = 0; i < els.length; i++) {
355+
let el = els[i],
356+
key = ZU.xpathText(el, 'td[@class="a-span3"]'),
357+
value = ZU.xpathText(el, 'td[@class="a-span9"]');
358+
if (key && value) {
359+
info[key.trim().toLowerCase()] = value.trim();
360+
}
361+
}
362+
}
358363
item.ISBN = getField(info, 'ISBN');
359364
if (item.ISBN) {
360365
item.ISBN = ZU.cleanISBN(item.ISBN);
361366
}
362-
367+
363368
// Date
364369
for (let i = 0; i < DATE.length; i++) {
365370
item.date = info[DATE[i]];
@@ -483,8 +488,7 @@ var testCases = [
483488
"language": "English",
484489
"libraryCatalog": "Amazon",
485490
"numPages": 320,
486-
"place": "New York",
487-
"publisher": "Harry N. Abrams",
491+
"publisher": "Amulet Paperbacks",
488492
"attachments": [
489493
{
490494
"title": "Amazon.com Link",
@@ -611,11 +615,6 @@ var testCases = [
611615
}
612616
]
613617
},
614-
{
615-
"type": "web",
616-
"url": "https://www.amazon.com/gp/registry/registry.html?ie=UTF8&id=1Q7ELHV59D7N&type=wishlist",
617-
"items": "multiple"
618-
},
619618
{
620619
"type": "web",
621620
"url": "https://www.amazon.fr/Candide-Fran%C3%A7ois-Marie-Voltaire-Arouet-dit/dp/2035866014/ref=sr_1_2?s=books&ie=UTF8&qid=1362329827&sr=1-2",
@@ -653,7 +652,7 @@ var testCases = [
653652
},
654653
{
655654
"type": "web",
656-
"url": "https://www.amazon.de/Fiktionen-Erz%C3%A4hlungen-Jorge-Luis-Borges/dp/3596105811/ref=sr_1_1?ie=UTF8&qid=1362329791&sr=8-1",
655+
"url": "https://www.amazon.de/Fiktionen-Erz%C3%A4hlungen-Jorge-Luis-Borges/dp/3596105811/ref=sr_1_1?ie=UTF8&qid=1362329791&sr=8-1&lang=de-de&language=de_DE",
657656
"items": [
658657
{
659658
"itemType": "book",
@@ -667,8 +666,8 @@ var testCases = [
667666
],
668667
"date": "1992",
669668
"ISBN": "9783596105816",
670-
"abstractNote": "Gleich bei seinem Erscheinen in den 40er Jahren löste Jorge Luis Borges’ erster Erzählband »Fiktionen« eine literarische Revolution aus. Erfundene Biographien, fiktive Bücher, irreale Zeitläufe und künstliche Realitäten verflocht Borges zu einem geheimnisvollen Labyrinth, das den Leser mit seinen Rätseln stets auf neue herausfordert. Zugleich begründete er mit seinen berühmten Erzählungen wie»›Die Bibliothek zu Babel«, «Die kreisförmigen Ruinen« oder»›Der Süden« den modernen »Magischen Realismus«. »Obwohl sie sich im Stil derart unterscheiden, zeigen zwei Autoren uns ein Bild des nächsten Jahrtausends: Joyce und Borges.« Umberto Eco",
671-
"edition": "15",
669+
"abstractNote": "Gleich bei seinem Erscheinen in den 40er Jahren löste Jorge Luis Borges’ erster Erzählband »Fiktionen« eine literarische Revolution aus. Erfundene Biographien, fiktive Bücher, irreale Zeitläufe und künstliche Realitäten verflocht Borges zu einem geheimnisvollen Labyrinth, das den Leser mit seinen Rätseln stets auf neue herausfordert. Zugleich begründete er mit seinen berühmten Erzählungen wie»›Die Bibliothek zu Babel«, «Die kreisförmigen Ruinen« oder»›Der Süden« den modernen »Magischen Realismus«.\n\n»Obwohl sie sich im Stil derart unterscheiden, zeigen zwei Autoren uns ein Bild des nächsten Jahrtausends: Joyce und Borges.« Umberto Eco",
670+
"edition": "16",
672671
"language": "Deutsch",
673672
"libraryCatalog": "Amazon",
674673
"numPages": 192,
@@ -752,7 +751,6 @@ var testCases = [
752751
"language": "Italiano",
753752
"libraryCatalog": "Amazon",
754753
"numPages": 72,
755-
"place": "Milano",
756754
"publisher": "Nord-Sud",
757755
"attachments": [
758756
{
@@ -864,13 +862,14 @@ var testCases = [
864862
],
865863
"date": "2012-08-02",
866864
"ISBN": "9780099578079",
867-
"abstractNote": "The year is 1Q84. This is the real world, there is no doubt about that. But in this world, there are two moons in the sky. In this world, the fates of two people, Tengo and Aomame, are closely intertwined. They are each, in their own way, doing something very dangerous. And in this world, there seems no way to save them both. Something extraordinary is starting.",
865+
"abstractNote": "The year is 1Q84. This is the real world, there is no doubt about that. But in this world, there are two moons in the sky. In this world, the fates of two people, Tengo and Aomame, are closely intertwined. They are each, in their own way, doing something very dangerous. And in this world, there seems no way to save them both. Something extraordinary is starting.",
868866
"edition": "Combined edition",
869867
"language": "English",
870868
"libraryCatalog": "Amazon",
871869
"numPages": 1328,
872870
"publisher": "Vintage",
873871
"shortTitle": "1Q84",
872+
"place": "London",
874873
"attachments": [
875874
{
876875
"title": "Amazon.com Link",
@@ -949,6 +948,7 @@ var testCases = [
949948
"language": "Japanese",
950949
"libraryCatalog": "Amazon",
951950
"publisher": "岩波書店",
951+
"abstractNote": "帯ありません。若干のスレはありますがほぼ普通です。小口、天辺に少しヤケがあります。中身は少しヤケはありますがきれいです。",
952952
"attachments": [
953953
{
954954
"title": "Amazon.com Link",
@@ -976,13 +976,12 @@ var testCases = [
976976
"creatorType": "author"
977977
}
978978
],
979-
"date": "2018-04-24",
979+
"date": "2018-08-24",
980980
"ISBN": "9781333821388",
981-
"abstractNote": "Excerpt from Studies in Saiva-SiddhantaEuropean Sanskritist, unaware perhaps of the bearings of the expression, rendered the collocation Parama-hamsa' into 'great goose'. The strictly pedagogic purist may endeavour to justify such puerile versions on etymological grounds, but they stand Self-condemned as mal-interpretations reflecting anything but the sense and soul of the original. Such lapses into unwitting ignorance, need never be expected in any of the essays contained in the present collection, as our author is not only a sturdy and indefatigable researcher in Tamil philosophic literature illuminative Of the Agamic religion, but has also, in his quest after Truth, freely utilised the services of those Indigenous savam's, who represent the highest water-mark of Hindu traditional learning and spiritual associations at the present-day.About the PublisherForgotten Books publishes hundreds of thousands of rare and classic books. Find more at www.forgottenbooks.comThis book is a reproduction of an important historical work. Forgotten Books uses state-of-the-art technology to digitally reconstruct the work, preserving the original format whilst repairing imperfections present in the aged copy. In rare cases, an imperfection in the original, such as a blemish or missing page, may be replicated in our edition. We do, however, repair the vast majority of imperfections successfully; any imperfections that remain are intentionally left to preserve the state of such historical works.",
981+
"abstractNote": "Excerpt from Studies in Saiva-SiddhantaEuropean Sanskritist, unaware perhaps of the bearings of the expression, rendered the collocation Parama-hamsa' into 'great goose'. The strictly pedagogic purist may endeavour to justify such puerile versions on etymological grounds, but they stand Self-condemned as mal-interpretations re?ecting anything but the sense and soul of the original. Such lapses into unwitting ignorance, need never be expected in any of the essays contained in the present collection, as our author is not only a sturdy and indefatigable researcher in Tamil philosophic literature illuminative Of the Agamic religion, but has also, in his quest after Truth, freely utilised the services of those Indigenous savam's, who represent the highest water-mark of Hindu traditional learning and spiritual associations at the present-day.",
982982
"language": "English",
983983
"libraryCatalog": "Amazon",
984-
"numPages": 398,
985-
"place": "Place of publication not identified",
984+
"numPages": 396,
986985
"publisher": "Forgotten Books",
987986
"attachments": [
988987
{
@@ -1025,6 +1024,7 @@ var testCases = [
10251024
"edition": "第 1st 版",
10261025
"libraryCatalog": "Amazon",
10271026
"publisher": "社会科学文献出版社",
1027+
"abstractNote": "《中国之翼》是一本书写了一段未被透露的航空编年史的篇章,它讲述了二战时期亚洲战场动荡的背景下的航空冒险的扣人心弦的故事。故事的主体是激动人心的真实的“空中兄弟连”的冒险事迹。正是这些人在二战期间帮助打开了被封锁的中国的天空,并勇敢的在各种冲突中勇敢守卫着它。这是一段值得被更多的中国人和美国人知晓并铭记的航空史和中美关系史。",
10281028
"attachments": [
10291029
{
10301030
"title": "Amazon.com Link",

0 commit comments

Comments
 (0)