Files
RSSHub/lib/routes/gov/customs/utils.ts
T
DIYgod 566f028aaf refactor: migrate browser automation to Playwright (#21901)
* refactor: migrate browser automation to Playwright

* ci: update browser checks for Playwright
2026-05-04 21:16:18 +08:00

19 lines
654 B
TypeScript

const host = 'http://www.customs.gov.cn';
const playwrightGet = async (url, browser) => {
const page = await browser.newPage();
await page.setExtraHTTPHeaders({ referer: host });
await page.setRequestInterception(true);
page.on('request', (request) => {
request.resourceType() === 'document' || request.resourceType() === 'script' ? request.continue() : request.abort();
});
await page.goto(url, {
waitUntil: 'domcontentloaded',
});
await page.waitForSelector('.pubCon');
const html = await page.evaluate(() => document.documentElement.innerHTML);
return html;
};
export { host, playwrightGet };