Skip to content

Commit

Permalink
Merge pull request #24 from io-monad/kakuyomu-fix
Browse files Browse the repository at this point in the history
fix(kakuyomu): Fix failed to scrape new Kakuyomu mypage
  • Loading branch information
io-monad authored Jun 15, 2016
2 parents 620aee4 + af87455 commit 47fd39e
Show file tree
Hide file tree
Showing 6 changed files with 510 additions and 107 deletions.
4 changes: 2 additions & 2 deletions app/scripts/lib/sites/kakuyomu/api/my-novel-lister.js
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand All @@ -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 };

Expand Down
2 changes: 1 addition & 1 deletion test/fake-server.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
23 changes: 16 additions & 7 deletions test/fixtures/kakuyomu/my-news-comment-list.json
Original file line number Diff line number Diff line change
@@ -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"
}
]
4 changes: 2 additions & 2 deletions test/fixtures/kakuyomu/my-novel-id-list.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[
"1177354054880772094",
"4852201425154996024"
"4852201425154996024",
"1177354054881227205"
]
52 changes: 26 additions & 26 deletions test/fixtures/kakuyomu/my-novel-list.json
Original file line number Diff line number Diff line change
@@ -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",
Expand All @@ -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
}
]
Loading

0 comments on commit 47fd39e

Please sign in to comment.