Files
RSSHub/lib/v2/aip/utils.js
T
Derekandgithub-actions[bot] 8d4dbb9a80 fix(route): update v2/scitation to v2/aip (#12955)
* fix(route): scitation/journal

* fix(docs): scitation/journal

* fix(docs): (en) scitation/journal

* chores

* fix(radar): scitation/journal

* fix(radar): scitation/journal

* fix(radar): scitation/journal

* style: auto format

* fix(route): mv scitation to aip

* fix(route): v2/AIP chores

* fix(docs): v2/aip docs

* fix(docs): chores: jounus/advanced/advanced-feed

* fix(docs): update en docs

* fix(docs): not right close the <RouteEn>

* fix(docs): correct some mistake

* Update lib/v2/aip/radar.js

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2023-08-19 20:44:11 +08:00

30 lines
806 B
JavaScript

const path = require('path');
const { art } = require('@/utils/render');
const puppeteerGet = 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.continue() : request.abort();
});
await page.goto(url, {
waitUntil: 'domcontentloaded',
});
const html = await page.evaluate(() => document.documentElement.innerHTML);
return html;
};
const renderDesc = (title, authors, doi, img) =>
art(path.join(__dirname, 'templates/description.art'), {
title,
authors,
doi,
img,
});
module.exports = {
puppeteerGet,
renderDesc,
};