Skip to content
Permalink
Browse files

Fix multiple items for douban.com (#1762)

The original Xpath ```//div/a[contains(@OnClick, "moreurl")]``` is not working and I replace it with ```//div[@Class="title"]/a'``` and modified following code in order to import multiple items in doulist or search result pages.
  • Loading branch information...
JanusChoi authored and zuphilip committed Oct 11, 2018
1 parent 8ce89b7 commit 21e60d603208f98e98cc909dd1a1191f94d5875c
Showing with 9 additions and 6 deletions.
  1. +9 −6 Douban.js
@@ -15,17 +15,17 @@
/*
Douban Translator
Copyright (C) 2009-2010 TAO Cheng, acestrong@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
@@ -207,9 +207,12 @@ function doWeb(doc, url) {
var articles = new Array();
if (detectWeb(doc, url) == "multiple") {
var items = {};
var titles = doc.evaluate('//div/h2/a[contains(@onclick, "moreurl")]', doc, null, XPathResult.ANY_TYPE, null);
var titles = ZU.xpath(doc, '//div[@class="title"]/a');
var title;
while (title = titles.iterateNext()) {
for (let i = 0; i < titles.length; i++){
title = titles[i];
Zotero.debug(title.href);
Zotero.debug(title.textContent);
items[title.href] = title.textContent;
}
Zotero.selectItems(items, function (items) {
@@ -276,4 +279,4 @@ var testCases = [
]
}
]
/** END TEST CASES **/
/** END TEST CASES **/

0 comments on commit 21e60d6

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