forked from DIYgod/RSSHub
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from DIYgod/master
merge
- Loading branch information
Showing
8 changed files
with
203 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
const axios = require('../../utils/axios'); | ||
const cheerio = require('cheerio'); | ||
const url = require('url'); | ||
|
||
const host = 'https://www.douban.com/explore/column/'; | ||
module.exports = async (ctx) => { | ||
const id = ctx.params.id; | ||
const link = url.resolve(host, id); | ||
const response = await axios.get(link); | ||
const $ = cheerio.load(response.data); | ||
const title = $('div.h1').text(); | ||
|
||
const list = $('div.item') | ||
.slice(0, 10) | ||
.map(function() { | ||
const info = { | ||
title: $(this) | ||
.find('div.title a') | ||
.text(), | ||
link: $(this) | ||
.find('div.title a') | ||
.attr('href'), | ||
author: $(this) | ||
.find('div.usr-pic a') | ||
.text(), | ||
}; | ||
return info; | ||
}) | ||
.get(); | ||
|
||
const out = await Promise.all( | ||
list.map(async (info) => { | ||
const title = info.title; | ||
const author = info.author; | ||
const itemUrl = info.link; | ||
|
||
const response = await axios.get(itemUrl); | ||
const $ = cheerio.load(response.data); | ||
const description = $('#link-report').html(); | ||
|
||
const single = { | ||
title: title, | ||
link: itemUrl, | ||
description: description, | ||
author: author, | ||
}; | ||
return Promise.resolve(single); | ||
}) | ||
); | ||
|
||
ctx.state.data = { | ||
title: `${title}-豆瓣发现`, | ||
link: link, | ||
item: out, | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
const axios = require('../../utils/axios'); | ||
const cheerio = require('cheerio'); | ||
|
||
module.exports = async (ctx) => { | ||
const id = ctx.params.id; | ||
const link = `http://www.woshipm.com/u/${id}`; | ||
const response = await axios.get(link); | ||
const $ = cheerio.load(response.data); | ||
const name = $('div.name').text(); | ||
|
||
const remark_api = `http://www.woshipm.com/__api/v1/users/${id}/bookmarks`; | ||
const response_api = await axios.get(remark_api); | ||
const list = response_api.data.payload.value; | ||
const out = await Promise.all( | ||
list.map(async (info) => { | ||
const title = info.title; | ||
const date = info.date; | ||
const itemUrl = info.permalink; | ||
|
||
const cache = await ctx.cache.get(itemUrl); | ||
if (cache) { | ||
return Promise.resolve(JSON.parse(cache)); | ||
} | ||
|
||
const response = await axios.get(itemUrl); | ||
const $ = cheerio.load(response.data); | ||
const description = $('div.grap') | ||
.html() | ||
.trim(); | ||
|
||
const single = { | ||
title: title, | ||
link: itemUrl, | ||
description: description, | ||
pubDate: new Date(date).toUTCString(), | ||
}; | ||
ctx.cache.set(itemUrl, JSON.stringify(single), 24 * 60 * 60); | ||
return Promise.resolve(single); | ||
}) | ||
); | ||
|
||
ctx.state.data = { | ||
title: `${name}的收藏-人人都是产品经理`, | ||
link: link, | ||
item: out, | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
const axios = require('../../utils/axios'); | ||
const cheerio = require('cheerio'); | ||
|
||
module.exports = async (ctx) => { | ||
const id = ctx.params.id; | ||
const link = `http://www.woshipm.com/u/${id}`; | ||
|
||
const response = await axios.get(link); | ||
const $ = cheerio.load(response.data); | ||
|
||
const name = $('div.name').text(); | ||
const list = $('div.postlist-item.u-clearfix div.content') | ||
.slice(0, 10) | ||
.map(function() { | ||
const info = { | ||
title: $(this) | ||
.find('h2.post-title a') | ||
.attr('title'), | ||
link: $(this) | ||
.find('h2.post-title a') | ||
.attr('href'), | ||
date: $(this) | ||
.find('time') | ||
.text(), | ||
}; | ||
return info; | ||
}) | ||
.get(); | ||
|
||
const out = await Promise.all( | ||
list.map(async (info) => { | ||
const title = info.title; | ||
const date = info.date; | ||
const itemUrl = info.link; | ||
|
||
const cache = await ctx.cache.get(itemUrl); | ||
if (cache) { | ||
return Promise.resolve(JSON.parse(cache)); | ||
} | ||
|
||
const response = await axios.get(itemUrl); | ||
const $ = cheerio.load(response.data); | ||
const description = $('div.grap') | ||
.html() | ||
.trim(); | ||
|
||
const single = { | ||
title: title, | ||
link: itemUrl, | ||
description: description, | ||
pubDate: new Date(date).toUTCString(), | ||
}; | ||
ctx.cache.set(itemUrl, JSON.stringify(single), 24 * 60 * 60); | ||
return Promise.resolve(single); | ||
}) | ||
); | ||
|
||
ctx.state.data = { | ||
title: `${name}的文章-人人都是产品经理`, | ||
link: link, | ||
item: out, | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters