From bd2f18c5c7f6b7c0526adce0440f0021cdfe9599 Mon Sep 17 00:00:00 2001 From: Tony Date: Wed, 15 Apr 2026 00:43:31 +0800 Subject: [PATCH] feat(route): add pixel update bulletins (#21740) --- lib/routes/android/pixel-update-bulletin.ts | 53 +++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 lib/routes/android/pixel-update-bulletin.ts diff --git a/lib/routes/android/pixel-update-bulletin.ts b/lib/routes/android/pixel-update-bulletin.ts new file mode 100644 index 000000000..ce1e3bfce --- /dev/null +++ b/lib/routes/android/pixel-update-bulletin.ts @@ -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, + }; +}