UNPKG

rsshub

Version:
23 lines (21 loc) 825 B
import { n as puppeteer_default } from "./puppeteer-DGmvuGvT.mjs"; import { t as getCookies } from "./puppeteer-utils-BK3JC9qW.mjs"; //#region lib/routes/nuaa/utils/pypasswaf.ts /** * async function 获取cookie * @desc 返回一个可用的cookie,使用 `got` 发起请求的时候,传入到`options.headers.cookie`即可 */ async function getCookie(host) { const browser = await puppeteer_default(); const page = await browser.newPage(); await page.setRequestInterception(true); page.on("request", (request) => { request.resourceType() === "document" || request.resourceType() === "script" ? request.continue() : request.abort(); }); await page.goto(host, { waitUntil: "networkidle0" }); const cookie = await getCookies(page); await browser.close(); return cookie; } //#endregion export { getCookie as t };