feat(route): add pixel update bulletins (#21740)

This commit is contained in:
Tony 2026-04-15 00:43:31 +08:00 committed by GitHub
parent cb0e63de6c
commit bd2f18c5c7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 53 additions and 0 deletions

View File

@ -0,0 +1,53 @@
import { load } from 'cheerio';
import type { Route } from '@/types';
import ofetch from '@/utils/ofetch';
import { parseDate } from '@/utils/parse-date';
export const route: Route = {
path: '/pixel-update-bulletin',
categories: ['program-update'],
example: '/android/pixel-update-bulletin',
radar: [
{
source: ['source.android.com/docs/security/bulletin/pixel', 'source.android.com'],
},
],
name: 'Pixel Update Bulletins',
maintainers: ['TonyRL'],
handler,
url: 'source.android.com/docs/security/bulletin/pixel',
};
async function handler() {
const baseUrl = 'https://source.android.com';
const link = `${baseUrl}/docs/security/bulletin/pixel`;
const response = await ofetch(link, {
headers: {
Cookie: 'signin=autosignin; cookies_accepted=true; django_language=en;',
},
});
const $ = load(response);
const list = $('table tr:has(td:first-child a)')
.toArray()
.map((item) => {
const $item = $(item);
const a = $item.find('td:nth-child(1) a');
return {
title: `Pixel Update Bulletin ${a.text()}`,
description: $item.find('td:nth-child(2)').html()?.trim(),
link: new URL(a.attr('href')!, baseUrl).href,
pubDate: parseDate($item.find('td:nth-child(3)').text()),
};
});
return {
title: $('head title').text(),
link,
image: $('link[rel="apple-touch-icon"]').attr('href'),
item: list,
};
}