终于找到一种可以解决 “请在微信客户端打开链接” 的方法,
const puppeteer = require("puppeteer");
const url =
"http://support.weixin.qq.com/cgi-bin/mmsupport-bin/readtemplate?t=page/android_exp__index";
const fs = require("fs");
const app = async function () {
const browser = await puppeteer.launch();
const page = await browser.newPage();
await page.emulate({
viewport: {
width: 400,
height: 700,
deviceScaleFactor: 1,
isMobile: true,
hasTouch: true,
},
userAgent:
"Mozilla/5.0 (Linux; Android 5.0; SM-N9100 Build/LRX21V) > AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 > Chrome/37.0.0.0 Mobile Safari/537.36 > MicroMessenger/6.0.2.56_r958800.520 NetType/WIFI Edg/90.0.4430.93",
});
await page.goto(url);
let bodyHTML = await page.evaluate(() => document.body.innerHTML);
await browser.close();
fs.writeFileSync("./index.html", bodyHTML);
};
app();