From af8745542098ecce51691a3afd27d1bbedafe46b Mon Sep 17 00:00:00 2001 From: io-monad Date: Wed, 15 Jun 2016 18:47:10 +0900 Subject: [PATCH] fix(kakuyomu): Fix failed to scrape new Kakuyomu mypage Closes #21 --- .../lib/sites/kakuyomu/api/my-novel-lister.js | 4 +- test/fake-server.conf.js | 2 +- .../kakuyomu/my-news-comment-list.json | 23 +- test/fixtures/kakuyomu/my-novel-id-list.json | 4 +- test/fixtures/kakuyomu/my-novel-list.json | 52 +- test/fixtures/kakuyomu/my.html | 532 +++++++++++++++--- 6 files changed, 510 insertions(+), 107 deletions(-) diff --git a/app/scripts/lib/sites/kakuyomu/api/my-novel-lister.js b/app/scripts/lib/sites/kakuyomu/api/my-novel-lister.js index f1a468a..b3b479a 100644 --- a/app/scripts/lib/sites/kakuyomu/api/my-novel-lister.js +++ b/app/scripts/lib/sites/kakuyomu/api/my-novel-lister.js @@ -56,7 +56,7 @@ export default class KakuyomuMyNovelLister { } _parseIdList($) { - return _.map($("#works-hasWorks > ul > li"), (item) => { + return _.map($("#works-hasWorks > ul > li.widget-list-child"), (item) => { const $item = $(item); const editUrl = $item.find("h3 > a").last().attr("href"); return editUrl.match(/\/works\/(\d+)/)[1]; @@ -69,7 +69,7 @@ export default class KakuyomuMyNovelLister { const authorUrl = resolve($("#profile > h2").first().children("a").attr("href")); const authorUserId = authorUrl.match(/\/users\/([^\/]+)/)[1]; - return _.map($("#works-hasWorks > ul > li"), (item) => { + return _.map($("#works-hasWorks > ul > li.widget-list-child"), (item) => { const $item = $(item); const novel = { authorName, authorUrl, authorUserId }; diff --git a/test/fake-server.conf.js b/test/fake-server.conf.js index 942ee7d..dc18747 100644 --- a/test/fake-server.conf.js +++ b/test/fake-server.conf.js @@ -8,7 +8,7 @@ export default { "kakuyomu/original-novel.html", "https://kakuyomu.jp/works/4852201425154996024/reviews": "kakuyomu/review-list.html", - "https://kakuyomu.jp/works/1177354054880772094/reviews": + "https://kakuyomu.jp/works/1177354054881227205/reviews": "kakuyomu/review-list-empty.html", "https://kakuyomu.jp/users/kadokawabooks/works": "kakuyomu/user-novel-list.html", diff --git a/test/fixtures/kakuyomu/my-news-comment-list.json b/test/fixtures/kakuyomu/my-news-comment-list.json index d169510..2780f85 100644 --- a/test/fixtures/kakuyomu/my-news-comment-list.json +++ b/test/fixtures/kakuyomu/my-news-comment-list.json @@ -1,11 +1,20 @@ [ { - "url": "https://kakuyomu.jp/users/io-monad/news/1177354054880926400#comment-1177354054880957198", - "id": "1177354054880957198", - "body": "別のユーザーでコメントのテストです。\nうまく動く…", - "articleTitle": "本日4月23日のマギハッカー更新はお休みいたします", - "articleUrl": "https://kakuyomu.jp/users/io-monad/news/1177354054880926400", - "userName": "@io-monad-test", - "userUrl": "https://kakuyomu.jp/users/io-monad-test" + "url": "https://kakuyomu.jp/users/io-monad/news/1177354054880909998#comment-1177354054881178630", + "id": "1177354054881178630", + "body": "のべらす、使ってみました!すごいですねコレ・・・…", + "articleTitle": "小説作者向けのカクヨム・小説家になろう Chrome 拡張を作りました", + "articleUrl": "https://kakuyomu.jp/users/io-monad/news/1177354054880909998", + "userName": "零識 無記名(mukina)", + "userUrl": "https://kakuyomu.jp/users/nishishikimukina" + }, + { + "url": "https://kakuyomu.jp/users/io-monad/news/1177354054880909998#comment-1177354054881178623", + "id": "1177354054881178623", + "body": "マギハッカーも大ファンです!いつも更新楽しみにし…", + "articleTitle": "小説作者向けのカクヨム・小説家になろう Chrome 拡張を作りました", + "articleUrl": "https://kakuyomu.jp/users/io-monad/news/1177354054880909998", + "userName": "零識 無記名(mukina)", + "userUrl": "https://kakuyomu.jp/users/nishishikimukina" } ] diff --git a/test/fixtures/kakuyomu/my-novel-id-list.json b/test/fixtures/kakuyomu/my-novel-id-list.json index 345aca7..4d02521 100644 --- a/test/fixtures/kakuyomu/my-novel-id-list.json +++ b/test/fixtures/kakuyomu/my-novel-id-list.json @@ -1,4 +1,4 @@ [ - "1177354054880772094", - "4852201425154996024" + "4852201425154996024", + "1177354054881227205" ] diff --git a/test/fixtures/kakuyomu/my-novel-list.json b/test/fixtures/kakuyomu/my-novel-list.json index e7efb4b..d48e4c3 100644 --- a/test/fixtures/kakuyomu/my-novel-list.json +++ b/test/fixtures/kakuyomu/my-novel-list.json @@ -1,23 +1,4 @@ [ - { - "authorName": "入出もなど", - "authorUrl": "https://kakuyomu.jp/users/io-monad", - "authorUserId": "io-monad", - "editUrl": "https://kakuyomu.jp/my/works/1177354054880772094", - "id": "1177354054880772094", - "newEpisodeUrl": "https://kakuyomu.jp/my/works/1177354054880772094/episodes/new", - "isFinished": false, - "isPrivate": true, - "title": "test", - "url": "https://kakuyomu.jp/works/1177354054880772094", - "episodeCount": 0, - "characterCount": 0, - "starCount": 0, - "followerCount": 0, - "rateCount": 0, - "latestEpisodeUrl": null, - "updatedAt": 1459609440000 - }, { "authorName": "入出もなど", "authorUrl": "https://kakuyomu.jp/users/io-monad", @@ -29,12 +10,31 @@ "isPrivate": false, "title": "マギハッカーの異世界ベンチャー起業術", "url": "https://kakuyomu.jp/works/4852201425154996024", - "episodeCount": 50, - "characterCount": 263019, - "starCount": 43, - "followerCount": 50, - "rateCount": 17, - "latestEpisodeUrl": "https://kakuyomu.jp/works/4852201425154996024/episodes/1177354054880768333", - "updatedAt": 1459594200000 + "episodeCount": 113, + "characterCount": 604220, + "starCount": 69, + "followerCount": 121, + "rateCount": 26, + "latestEpisodeUrl": "https://kakuyomu.jp/works/4852201425154996024/episodes/1177354054881222234", + "updatedAt": 1465899960000 + }, + { + "authorName": "入出もなど", + "authorUrl": "https://kakuyomu.jp/users/io-monad", + "authorUserId": "io-monad", + "editUrl": "https://kakuyomu.jp/my/works/1177354054881227205", + "id": "1177354054881227205", + "newEpisodeUrl": "https://kakuyomu.jp/my/works/1177354054881227205/episodes/new", + "isFinished": true, + "isPrivate": false, + "title": "テスト小説", + "url": "https://kakuyomu.jp/works/1177354054881227205", + "episodeCount": 1, + "characterCount": 76, + "starCount": 0, + "followerCount": 0, + "rateCount": 0, + "latestEpisodeUrl": null, + "updatedAt": null } ] diff --git a/test/fixtures/kakuyomu/my.html b/test/fixtures/kakuyomu/my.html index 48d2311..3ad008c 100644 --- a/test/fixtures/kakuyomu/my.html +++ b/test/fixtures/kakuyomu/my.html @@ -9,9 +9,9 @@ 小説管理 - カクヨム - - - + + + @@ -66,20 +66,26 @@

ログイン中@io-monad