-
Notifications
You must be signed in to change notification settings - Fork 7.7k
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/meta): add AI at Meta Blog #17408
Closed
+61
−0
Closed
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
44f57f4
create namespace
canonnizq dd6092e
create blog.ts
canonnizq b7dc08e
category finding
canonnizq 3e16e63
fix typos
canonnizq 686f38a
fix linter errors
canonnizq 8d89cca
fix searching
canonnizq 676ccba
correct class name
canonnizq 0c3c75b
(hopefully) fix search
canonnizq 9ec7d22
Update lib/routes/aimeta/blog.ts
canonnizq aa4403e
per comments on pull request
canonnizq f72267d
fix path
canonnizq b8c5739
Merge branch 'aimeta' of https://github.com/canonnizq/RSSHub into aimeta
canonnizq 73cacb1
rename from aimeta to meta
canonnizq c5abfba
Merge branch 'DIYgod:master' into meta
canonnizq 396f885
fix linter errors
canonnizq 819ffea
testing if puppeteer works
canonnizq 0982952
try longer load time & fix lint errors
canonnizq File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 { parseDate } from '@/utils/parse-date'; | ||
import { load } from 'cheerio'; | ||
import logger from '@/utils/logger'; | ||
import puppeteer from '@/utils/puppeteer'; | ||
import cache from '@/utils/cache'; | ||
|
||
export const route: Route = { | ||
path: '/blog', | ||
categories: ['blog'], | ||
example: '/meta/blog', | ||
radar: [{ source: ['ai.meta.com/blog/'] }], | ||
name: 'Blog', | ||
maintainers: ['canonnizq'], | ||
handler | ||
}; | ||
|
||
async function handler() { | ||
const baseUrl = 'https://ai.meta.com'; | ||
|
||
const browser = await puppeteer(); | ||
const page = await browser.newPage(); | ||
await page.setRequestInterception(true); | ||
|
||
page.on('request', (request) => { | ||
request.resourceType() === 'document' ? request.continue() : request.abort(); | ||
}); | ||
|
||
const link = `${baseUrl}/blog/`; | ||
logger.http(`Requesting ${link}`); | ||
await page.goto(link, { | ||
waitUntil: 'load', | ||
}); | ||
|
||
const response = await page.content(); | ||
page.close(); | ||
|
||
const $ = load(response); | ||
const items = $('div._ams_') | ||
.toArray().map((item) => ({ | ||
category: $(item).find('p._amt0').text(), | ||
link: $(item).find('a._amt1').attr('href'), | ||
title: $(item).find('a._amt1 p._amt2').text(), | ||
description: $(item).find('div._4ik4._4ik5 p._amt3').text(), | ||
pubDate: parseDate($(item).find('p._amt4').text()) | ||
})); | ||
|
||
browser.close(); | ||
|
||
return { | ||
title: 'AI at Meta Blog', | ||
link: 'https://ai.meta.com/blog/', | ||
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,6 @@ | ||
import type { Namespace } from '@/types'; | ||
|
||
export const namespace: Namespace = { | ||
name: 'AI at Meta', | ||
url: 'meta.com', | ||
}; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Check failure
Code scanning / ESLint
Disallow unused variables Error