fix: /gamer/gnn/ (#6689)

* On branch master
 Your branch is up to date with 'origin/master'.

 Changes to be committed:
	modified:   docs/traditional-media.md
	modified:   lib/router.js
	new file:   lib/routes/yomiuri/national.js
	new file:   lib/routes/yomiuri/top.js

* On branch master
 Your branch is ahead of 'origin/master' by 1 commit.

 Changes to be committed:
	modified:   docs/game.md
	modified:   lib/router.js
	new file:   lib/routes/gamer/index.js

* On branch master
 Your branch is ahead of 'origin/master' by 3 commits.
   (use "git push" to publish your local commits)

 Changes to be committed:
	new file:   lib/router.js

* On branch master
 Your branch is ahead of 'origin/master' by 4 commits.
   (use "git push" to publish your local commits)

 Changes to be committed:
	modified:   lib/router.js

* On branch master
 Your branch is up to date with 'origin/master'.

 Changes to be committed:
	modified:   lib/routes/gamer/index.js

* On branch master
 Your branch is up to date with 'origin/master'.
 Changes to be committed:
	new file:   New Text Document.txt
	modified:   lib/routes/gamer/index.js

* On branch master
 Your branch is up to date with 'origin/master'.
 Changes to be committed:
	modified:   lib/routes/gamer/index.js

* On branch master
 Your branch is up to date with 'origin/master'.
 Changes to be committed:
	modified:   lib/routes/gamer/index.js

* On branch master
 Your branch is up to date with 'origin/master'.
 Changes to be committed:
	modified:   lib/routes/gamer/index.js

* On branch master
 Your branch is ahead of 'origin/master' by 1 commit.
   (use "git push" to publish your local commits)
 Changes to be committed:
	modified:   docs/game.md
	modified:   docs/traditional-media.md
	modified:   lib/router.js
	new file:   lib/routes/gamer/gnn_index.js
	deleted:    lib/routes/gamer/index.js
	new file:   lib/routes/yomiuri/news.js
	eleted:    lib/routes/yomiuri/top.js

* On branch master
 Your branch is up to date with 'origin/master'.

 Changes to be committed:
	modified:   lib/routes/gamer/gnn_index.js

* On branch master
 Your branch is up to date with 'origin/master'.

 Changes to be committed:
	modified:   docs/game.md
	modified:   lib/routes/gamer/gnn_index.js

* On branch master
 Your branch is up to date with 'origin/master'.

 Changes to be committed:
	new file:   docs/game.md
	new file:   docs/traditional-media.md
	new file:   lib/router.js

* On branch master
 Your branch is up to date with 'origin/master'.

 Changes to be committed:
	deleted:    lib/routes/yomiuri/national.js

* On branch master
 Your branch is up to date with 'origin/master'.

 Changes to be committed:
	modified:   lib/routes/gamer/gnn_index.js
	modified:   lib/routes/yomiuri/news.js

* [CodeFactor] Apply fixes to commit 9679b09

[ci skip] [skip ci]

* On branch master
 Your branch is up to date with 'origin/master'.

 Changes to be committed:
	modified:   lib/routes/gamer/gnn_index.js
	modified:   lib/routes/yomiuri/news.js

* On branch master
 Your branch is ahead of 'origin/master' by 2 commits.
   (use "git push" to publish your local commits)

 Changes to be committed:
	modified:   lib/routes/gamer/gnn_index.js

* [CodeFactor] Apply fixes

[ci skip] [skip ci]

* On branch master
 Your branch is behind 'origin/master' by 1 commit, and can be fast-forwarded.
   (use "git pull" to update your local branch)

 Changes to be committed:
	modified:   lib/routes/gamer/gnn_index.js
	modified:   lib/routes/yomiuri/news.js

* On branch master
 Your branch is ahead of 'origin/master' by 2 commits.
   (use "git push" to publish your local commits)

 Changes to be committed:
	modified:   lib/routes/yomiuri/news.js

* On branch master
 Your branch is up to date with 'origin/master'.

 Changes to be committed:
	modified:   lib/routes/gamer/gnn_index.js
	modified:   lib/routes/yomiuri/news.js

* On branch master
 Your branch is up to date with 'origin/master'.

 Changes to be committed:
	modified:   lib/routes/gamer/gnn_index.js

* On branch master
 Your branch is up to date with 'origin/master'.

 Changes to be committed:
	modified:   lib/routes/gamer/gnn_index.js

* On branch master
 Your branch is up to date with 'origin/master'.

 Changes to be committed:
	modified:   docs/game.md
	modified:   docs/traditional-media.md

* On branch master
 Your branch is up to date with 'origin/master'.

 Changes to be committed:
	modified:   docs/game.md
	modified:   lib/routes/gamer/gnn_index.js
	modified:   lib/routes/yomiuri/news.js

* On branch master
 Your branch is up to date with 'origin/master'.

 Changes to be committed:
	modified:   lib/router.js

* fix gnn.gamer.com.tw image display error

* support more category, fix article form home.gamer

* merge upstream

* add nikkei

* add free article filter

* fetch upstream

* fix text fetching error from home.gamer.com.tw

* merge upstream/master

* fix nikkei/news

* fix article dumplicate error, fix author grabbing error

Co-authored-by: codefactor-io <support@codefactor.io>
This commit is contained in:
Arracc 2021-01-14 05:14:43 +08:00 committed by GitHub
parent 23fad78286
commit 5df4050a8c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 5 deletions

View File

@ -84,30 +84,28 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map(async (item) => {
let author = '';
item.description = await ctx.cache.tryGet(item.link, async () => {
const response = await got.get(item.link);
let component = '';
const urlReg = /window.location.replace\('.*'/g;
if (response.body.search(urlReg) < 0) {
const $ = cheerio.load(response.data);
item.author = $('span.GN-lbox3C').text().split('')[0].split(' 報導')[0].split(' 提供')[0].split(' 同意授權轉載')[0].replace('', '');
component = $('div.GN-lbox3B').html();
author = $('span.GN-lbox3C').text().split('')[0].split(' 報導')[0].split(' 提供')[0].split(' 同意授權轉載')[0].replace('', '');
} else {
const newUrl = response.body.match(urlReg)[0].split('(')[1].replace(/'/g, '');
const _response = await got.get(newUrl);
const _$ = cheerio.load(_response.data);
item.author = _$('span.ST1').text().split('│', 2)[0].split('作者:')[1];
component = _$('div.MSG-list8C').html();
if (!component) {
item.author = _$('a.caption-text.primary').text();
component = _$('div.text-paragraph').html();
}
item.link = newUrl;
author = _$('span.ST1').text().split('│', 2)[0].split('作者:')[1];
}
component = component.replace(/\b(data-src)\b/g, 'src');
return component;
});
item.author = author;
return item;
})
);