forked from DIYgod/RSSHub
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(route): add Andy Pavlo Blog (DIYgod#18447)
- Loading branch information
Showing
2 changed files
with
62 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import { Route } from '@/types'; | ||
import got from '@/utils/got'; | ||
import { load } from 'cheerio'; | ||
import { parseDate } from '@/utils/parse-date'; | ||
|
||
async function getArticles() { | ||
const url = 'https://www.cs.cmu.edu/~pavlo/blog/index.html'; | ||
const { data: res } = await got(url); | ||
const $ = load(res); | ||
|
||
const list = $('.row.mb-3') | ||
.toArray() | ||
.map((element) => { | ||
const $item = $(element); | ||
const $title = $item.find('h4 a'); | ||
const $date = $item.find('.text-muted'); | ||
const $description = $item.find('p'); | ||
|
||
return { | ||
title: $title.text().trim(), | ||
link: $title.attr('href'), | ||
description: $description.text().trim(), | ||
pubDate: parseDate($date.attr('title')), | ||
guid: $title.attr('href'), | ||
}; | ||
}); | ||
return list; | ||
} | ||
|
||
export const route: Route = { | ||
path: '/andypavlo/blog', | ||
categories: ['blog'], | ||
example: '/cmu/andypavlo/blog', | ||
parameters: {}, | ||
features: { | ||
requireConfig: false, | ||
requirePuppeteer: false, | ||
antiCrawler: false, | ||
supportBT: false, | ||
supportPodcast: false, | ||
supportScihub: false, | ||
}, | ||
name: 'Andy Pavlo Blog', | ||
maintainers: ['mocusez'], | ||
handler, | ||
}; | ||
|
||
async function handler() { | ||
const articles = await getArticles(); | ||
return { | ||
title: 'Andy Pavlo - Carnegie Mellon University', | ||
link: 'https://www.cs.cmu.edu/~pavlo/blog/index.html', | ||
item: articles, | ||
}; | ||
} |
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,7 @@ | ||
import type { Namespace } from '@/types'; | ||
|
||
export const namespace: Namespace = { | ||
name: 'Carnegie Mellon University', | ||
url: 'www.cmu.edu', | ||
lang: 'en', | ||
}; |