-
Notifications
You must be signed in to change notification settings - Fork 7.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: NeverBehave <[email protected]>
- Loading branch information
1 parent
9e6aaf2
commit a87ecdf
Showing
4 changed files
with
122 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
const got = require('@/utils/got'); | ||
const cheerio = require('cheerio'); | ||
|
||
module.exports = async (ctx) => { | ||
const id = ctx.params.id || '139'; | ||
|
||
const rootUrl = 'http://wanwansub.com'; | ||
const currentUrl = `${rootUrl}/node/${id}`; | ||
const response = await got({ | ||
method: 'get', | ||
url: currentUrl, | ||
}); | ||
|
||
const $ = cheerio.load(response.data); | ||
|
||
const list = $('.pg-item a') | ||
.slice(0, 10) | ||
.map((_, item) => { | ||
item = $(item); | ||
return { | ||
title: item.text(), | ||
link: `${rootUrl}${item.attr('href')}`, | ||
}; | ||
}) | ||
.get(); | ||
|
||
const items = await Promise.all( | ||
list.map( | ||
async (item) => | ||
await ctx.cache.tryGet(item.link, async () => { | ||
const detailResponse = await got({ | ||
method: 'get', | ||
url: item.link, | ||
}); | ||
const content = cheerio.load(detailResponse.data); | ||
|
||
content('.button').remove(); | ||
|
||
const links = detailResponse.data.match(/<a href="magnet:(.*?)" target="_self">磁力<\/a>/g); | ||
|
||
if (links) { | ||
item.enclosure_type = 'application/x-bittorrent'; | ||
item.enclosure_url = links.pop().match(/<a href="(.*)" target="_self">磁力<\/a>/)[1]; | ||
} | ||
|
||
item.description = content('.content-box').html(); | ||
|
||
return item; | ||
}) | ||
) | ||
); | ||
|
||
ctx.state.data = { | ||
title: $('title').text(), | ||
link: currentUrl, | ||
item: items, | ||
}; | ||
}; |
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,44 @@ | ||
const got = require('@/utils/got'); | ||
const cheerio = require('cheerio'); | ||
|
||
module.exports = async (ctx) => { | ||
const id = ctx.params.id; | ||
|
||
const rootUrl = 'http://wanwansub.com'; | ||
const currentUrl = `${rootUrl}/info/${id}`; | ||
const response = await got({ | ||
method: 'get', | ||
url: currentUrl, | ||
}); | ||
|
||
const $ = cheerio.load(response.data); | ||
|
||
const items = $('.lightbox-image') | ||
.nextAll('p') | ||
.slice(3) | ||
.map((_, item) => { | ||
const i = {}; | ||
|
||
item = $(item); | ||
|
||
item.find('a').each(function () { | ||
if ($(this).text() === '磁力') { | ||
i.enclosure_url = $(this).attr('href'); | ||
i.enclosure_type = 'application/x-bittorrent'; | ||
} | ||
}); | ||
|
||
i.description = `<p>${item.html()}</p>`; | ||
i.title = item.text().split(' ')[0]; | ||
i.link = currentUrl; | ||
|
||
return i; | ||
}) | ||
.get(); | ||
|
||
ctx.state.data = { | ||
title: $('title').text(), | ||
link: currentUrl, | ||
item: items, | ||
}; | ||
}; |
a87ecdf
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs: