-
Notifications
You must be signed in to change notification settings - Fork 7.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(route): add orcid #7582
feat(route): add orcid #7582
Changes from 22 commits
5431f17
c3ce5e7
9fa439c
3255f63
dadbb6f
7fd967b
703ccaa
556db62
20bf6ff
17934e2
279003f
e378a4b
c38f2db
09cd835
1db9ab4
4fdd89d
288c203
15df7a1
fd005b8
ec5048e
864e9c9
a77e52f
f43d39b
fcd0e07
055480b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -407,6 +407,7 @@ router.get('/sexinsex/:id/:type?', require('./routes/sexinsex/index')); | |
router.get('/gcores/category/:category', require('./routes/gcores/category')); | ||
|
||
// 国家地理 | ||
router.get('/natgeo/dailyselection', require('./routes/natgeo/dailyselection')); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unnecessary changes |
||
router.get('/natgeo/dailyphoto', require('./routes/natgeo/dailyphoto')); | ||
router.get('/natgeo/:cat/:type?', require('./routes/natgeo/natgeo')); | ||
|
||
|
@@ -4085,4 +4086,7 @@ router.get('/hugo/releases', require('./routes/hugo/releases')); | |
// OR | ||
router.get('/or/:id?', require('./routes/or')); | ||
|
||
// ORCID | ||
router.get('/orcid/:id?', require('./routes/orcid')); | ||
|
||
module.exports = router; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,35 @@ | ||
const got = require('@/utils/got'); | ||
const cheerio = require('cheerio'); | ||
|
||
module.exports = async (ctx) => { | ||
const today = new Date(); | ||
const year = today.getFullYear(); | ||
const month = today.getMonth() + 1; | ||
const browser = await require('@/utils/puppeteer')(); | ||
const page = await browser.newPage(); | ||
const link = 'https://www.nationalgeographic.com/photo-of-the-day/media-spotlight/'; | ||
await page.goto(link); | ||
const html = await page.evaluate( | ||
() => | ||
document.querySelector('div.InlineGallery').innerHTML | ||
); | ||
browser.close(); | ||
|
||
const api = `https://www.nationalgeographic.com/content/photography/en_US/photo-of-the-day/_jcr_content/.gallery.${year}-${month}.json`; | ||
const response = await got.get(api); | ||
const items = response.data.items; | ||
const $ = cheerio.load(html); | ||
|
||
const out = items.slice(0, 10).map((item) => { | ||
const info = { | ||
title: item.image.title, | ||
author: item.image.credit && item.image.credit.replace('Photograph by ', ''), | ||
link: item.pageUrl, | ||
description: `<img src="${item.image.uri}">` + item.image.caption, | ||
}; | ||
return info; | ||
}); | ||
const imgUrl = $('img').attr('src'); | ||
const title = $('p.Caption__Title').text(); | ||
const description = $('span.RichText').text(); | ||
const author = $('span.Caption__Credit').text(); | ||
|
||
const out = new Array; | ||
|
||
const info = { | ||
title: title, | ||
link: link, | ||
description: `<img src="${imgUrl}"><br>` + 'Photography by: ' + author + '<br>' + description, | ||
}; | ||
out.push(info); | ||
|
||
ctx.state.data = { | ||
title: 'Photo of the Day', | ||
link: 'https://www.nationalgeographic.com/photography/photo-of-the-day/', | ||
title: 'Photo Of The Day', | ||
link: link, | ||
item: out, | ||
}; | ||
}; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unnecessary changes |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
const got = require('@/utils/got'); | ||
const timezone = require('@/utils/timezone'); | ||
const { | ||
parseDate | ||
} = require('@/utils/parse-date'); | ||
|
||
module.exports = async (ctx) => { | ||
const host = 'http://dili.bdatu.com/jiekou/mains/p1.html'; | ||
const data = await got.get(host); | ||
|
||
let sort = 0; | ||
let addtime = ''; | ||
|
||
for (let i = 0; i < data.data.album.length; i++) { | ||
if (parseInt(data.data.album[i].ds) === 1) { | ||
sort = data.data.album[i].sort; | ||
addtime = data.data.album[i].addtime; | ||
break; | ||
} | ||
} | ||
const api = 'http://dili.bdatu.com/jiekou/albums/a' + sort + '.html'; | ||
const response = await got.get(api); | ||
const items = response.data.picture; | ||
const out = new Array; | ||
|
||
items.map((item) => { | ||
const info = { | ||
title: item.title, | ||
link: item.url, | ||
description: `<img src="${item.url}"><br>` + item.content, | ||
pubDate: timezone(parseDate(addtime), +0), | ||
guid: item.id, | ||
}; | ||
out.push(info); | ||
return info; | ||
}); | ||
|
||
ctx.state.data = { | ||
title: 'Photo of the Daily Selection', | ||
link: api, | ||
item: out, | ||
}; | ||
}; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unnecessary changes |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,45 @@ | ||||||
const got = require('@/utils/got'); | ||||||
|
||||||
module.exports = async (ctx) => { | ||||||
const id = ctx.params.id || ''; | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
const rootUrl = 'https://orcid.org/'; | ||||||
const currentUrl = `${rootUrl}${id ? `${id}/worksPage.json?offset=0&sort=date&sortAsc=false&pageSize=20` : ''}`; | ||||||
const response = await got.get(currentUrl); | ||||||
|
||||||
const items = response.data.groups; | ||||||
const works = new Array; | ||||||
const out = new Array; | ||||||
|
||||||
for (let i = 0; i < items.length; i++) { | ||||||
for (let j = 0; j < items[i].works.length; j++) { | ||||||
works.push(items[i].works[j]); | ||||||
} | ||||||
} | ||||||
|
||||||
works.map((work) => { | ||||||
let Str = ''; | ||||||
|
||||||
for (let l = 0; l < work.workExternalIdentifiers.length; l++) { | ||||||
if (work.workExternalIdentifiers[l].url) { | ||||||
Str = Str + work.workExternalIdentifiers[l].externalIdentifierType.value + ': ' + work.workExternalIdentifiers[l].externalIdentifierId.value + '(URL: ' + work.workExternalIdentifiers[l].url.value + ')<br>'; | ||||||
} else { | ||||||
Str = Str + work.workExternalIdentifiers[l].externalIdentifierType.value + ': ' + work.workExternalIdentifiers[l].externalIdentifierId.value + '<br>'; | ||||||
} | ||||||
} | ||||||
|
||||||
const info = { | ||||||
title: work.title.value, | ||||||
link: work.url, | ||||||
description: `<h2>${work.title.value}</h2><h3>${work.journalTitle.value}</h3><span>${work.publicationDate.year ? `${work.publicationDate.year}-` : ``}${work.publicationDate.month}${work.publicationDate.day ? `-${work.publicationDate.day}` : ``} | ${work.workType.value}</span><br><span>${Str}</span><span>Source: ${work.sourceName}`, | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please use art-template to create HTML #8359 |
||||||
guid: work.putCode.value, | ||||||
}; | ||||||
out.push(info); | ||||||
return info; | ||||||
}); | ||||||
|
||||||
ctx.state.data = { | ||||||
title: 'ORCID Works List', | ||||||
link: currentUrl, | ||||||
item: out, | ||||||
}; | ||||||
}; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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.
Unnecessary changes