mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-08 14:07:54 +08:00
* fix(route): scitation - use Puppeteer due to the obstacle by cloudflare challenge * feat: update utils.js and journal.js * feat: prepare for section.js * feat: add section.js * fix(section.js): fix "section" length undifine error * feat: format * update(docs): add puppeteer="1"
30 lines
806 B
JavaScript
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,
|
|
};
|