|
|
@ -4,32 +4,49 @@ const {jsdomFromText, browser, jsdomFromUrl} = require("sdenv"); |
|
|
|
const {Script} = require("vm"); |
|
|
|
const {Script} = require("vm"); |
|
|
|
let fs = require('fs'); |
|
|
|
let fs = require('fs'); |
|
|
|
const express = require("express"); |
|
|
|
const express = require("express"); |
|
|
|
const cheerio = require('cheerio'); |
|
|
|
// const cheerio = require('cheerio');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const app = express(); |
|
|
|
// const app = express();
|
|
|
|
|
|
|
|
|
|
|
|
var baseUrl = "https://app.yunnan.chinatax.gov.cn" |
|
|
|
var baseUrl = "https://app.yunnan.chinatax.gov.cn" |
|
|
|
let url = `https://app.yunnan.chinatax.gov.cn/xxmh/html/dfts/index_frame.html`; |
|
|
|
let url = `https://app.yunnan.chinatax.gov.cn/xxmh/html/dfts/index_frame.html`; |
|
|
|
|
|
|
|
|
|
|
|
async function extracted(cookieJar) { |
|
|
|
// async function extracted(cookieJar) {
|
|
|
|
const [jsdomer] = await jsdomFromUrl({ |
|
|
|
// const [jsdomer] = await jsdomFromUrl({
|
|
|
|
proxy: 'http://127.0.0.1:8080', |
|
|
|
// // proxy: 'http://127.0.0.1:8080',
|
|
|
|
strictSSL: false, |
|
|
|
// strictSSL: false,
|
|
|
|
userAgent: 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36', |
|
|
|
// userAgent: 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36',
|
|
|
|
}, cookieJar); |
|
|
|
// }, cookieJar);
|
|
|
|
const dom = await jsdomer(url); |
|
|
|
// const dom = await jsdomer(url);
|
|
|
|
|
|
|
|
//
|
|
|
|
console.log(dom.serialize()) |
|
|
|
// console.log(dom.serialize())
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
function loadJs(window, jsText) { |
|
|
|
|
|
|
|
// 加载js
|
|
|
|
|
|
|
|
let js = ''; |
|
|
|
|
|
|
|
// 加载 页面上的js
|
|
|
|
|
|
|
|
const allScript = window.document.querySelectorAll('script[r="m"]'); |
|
|
|
|
|
|
|
for (let i = 0; i < allScript.length; i++) { |
|
|
|
|
|
|
|
const script = allScript[i]; |
|
|
|
|
|
|
|
let attr = script.textContent; |
|
|
|
|
|
|
|
if (attr) { |
|
|
|
|
|
|
|
js += attr |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
js += jsText |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
js += ";\n" |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return js; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function loadPages(urlBase64, jsBase64, htmlBase64, cookieBase64, userAgentBase64, ts) { |
|
|
|
async function loadPages(urlBase64, jsBase64, htmlBase64, cookieBase64, userAgentBase64, ts) { |
|
|
|
const htmlText = htmlBase64; |
|
|
|
const htmlText = htmlBase64; |
|
|
|
const jsText = jsBase64; |
|
|
|
const jsText = jsBase64; |
|
|
|
|
|
|
|
|
|
|
|
const [jsDom, cookieJar] = jsdomFromText({ |
|
|
|
const [jsDom, cookieJar] = jsdomFromText({ |
|
|
|
proxy: 'http://127.0.0.1:8080', |
|
|
|
// proxy: 'http://127.0.0.1:8080',
|
|
|
|
url: url, |
|
|
|
url: url, |
|
|
|
referrer: url, |
|
|
|
referrer: url, |
|
|
|
contentType: "text/html", |
|
|
|
contentType: "text/html", |
|
|
@ -41,11 +58,11 @@ function loadPages(urlBase64, jsBase64, htmlBase64, cookieBase64, userAgentBase6 |
|
|
|
|
|
|
|
|
|
|
|
window = dom.window |
|
|
|
window = dom.window |
|
|
|
// 加载 window.$_ts
|
|
|
|
// 加载 window.$_ts
|
|
|
|
let $ = cheerio.load(htmlText); |
|
|
|
// let $ = cheerio.load(htmlText);
|
|
|
|
let nextAll = $('script[r=m]'); |
|
|
|
// let nextAll = $('script[r=m]');
|
|
|
|
|
|
|
|
|
|
|
|
let trendJs = $('script').first().html(); |
|
|
|
// let trendJs = $('script').first().html();
|
|
|
|
let js = trendJs + ";\n" + jsText |
|
|
|
// let js = trendJs + ";\n" + jsText
|
|
|
|
// nextAll.each((index, element) => {
|
|
|
|
// nextAll.each((index, element) => {
|
|
|
|
// let attr = $(element).html();
|
|
|
|
// let attr = $(element).html();
|
|
|
|
// if (attr) {
|
|
|
|
// if (attr) {
|
|
|
@ -59,13 +76,47 @@ function loadPages(urlBase64, jsBase64, htmlBase64, cookieBase64, userAgentBase6 |
|
|
|
cookieJar.setCookieSync(cookieBase64, baseUrl); |
|
|
|
cookieJar.setCookieSync(cookieBase64, baseUrl); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
window.onbeforeunload = async (url) => { |
|
|
|
window.onbeforeunload = async (url) => { |
|
|
|
|
|
|
|
|
|
|
|
const cookies = cookieJar.getCookieStringSync(baseUrl); |
|
|
|
const cookies = cookieJar.getCookieStringSync(baseUrl); |
|
|
|
console.debug(`${url} 生成cookie:`, cookies); |
|
|
|
console.debug(`${url} 生成cookie:`, cookies); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// let fff = await fetch("https://app.yunnan.chinatax.gov.cn/xxmh/html/dfts/index_frame.html", {
|
|
|
|
|
|
|
|
// "headers": {
|
|
|
|
|
|
|
|
// "accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7",
|
|
|
|
|
|
|
|
// "accept-language": "zh-CN,zh;q=0.9",
|
|
|
|
|
|
|
|
// "cache-control": "no-cache",
|
|
|
|
|
|
|
|
// "pragma": "no-cache",
|
|
|
|
|
|
|
|
// "sec-ch-ua": "\"Not/A)Brand\";v=\"8\", \"Chromium\";v=\"126\", \"Google Chrome\";v=\"126\"",
|
|
|
|
|
|
|
|
// "sec-ch-ua-mobile": "?0",
|
|
|
|
|
|
|
|
// "sec-ch-ua-platform": "\"Linux\"",
|
|
|
|
|
|
|
|
// "sec-fetch-dest": "document",
|
|
|
|
|
|
|
|
// "sec-fetch-mode": "navigate",
|
|
|
|
|
|
|
|
// "sec-fetch-site": "same-origin",
|
|
|
|
|
|
|
|
// "upgrade-insecure-requests": "1",
|
|
|
|
|
|
|
|
// "cookie": cookies,
|
|
|
|
|
|
|
|
// "Referer": "https://app.yunnan.chinatax.gov.cn/xxmh/html/dfts/index_frame.html",
|
|
|
|
|
|
|
|
// }, "body": null, "method": "GET"
|
|
|
|
|
|
|
|
// });
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
// console.log(fff.status, fff.statusText)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
window.close(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
browser(dom.window, 'chrome'); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let js = loadJs(window, jsText); |
|
|
|
|
|
|
|
let script = new Script(js); |
|
|
|
|
|
|
|
let internalVMContext = dom.getInternalVMContext(); |
|
|
|
|
|
|
|
// 执行 js
|
|
|
|
|
|
|
|
script.runInContext(internalVMContext); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const cookies = cookieJar.getCookieStringSync(baseUrl); |
|
|
|
|
|
|
|
|
|
|
|
let fff = await fetch("https://app.yunnan.chinatax.gov.cn/xxmh/html/dfts/index_frame.html", { |
|
|
|
let fff = await fetch("https://app.yunnan.chinatax.gov.cn/xxmh/html/dfts/index_frame.html", { |
|
|
|
"headers": { |
|
|
|
"headers": { |
|
|
|
"accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7", |
|
|
|
"accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7", |
|
|
@ -85,18 +136,6 @@ function loadPages(urlBase64, jsBase64, htmlBase64, cookieBase64, userAgentBase6 |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
console.log(fff.status, fff.statusText) |
|
|
|
console.log(fff.status, fff.statusText) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
window.close(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
browser(dom.window, 'chrome'); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let script = new Script(js); |
|
|
|
|
|
|
|
let internalVMContext = dom.getInternalVMContext(); |
|
|
|
|
|
|
|
// 执行 js
|
|
|
|
|
|
|
|
script.runInContext(internalVMContext); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -104,7 +143,7 @@ async function test() { |
|
|
|
let response = await fetch(url, {"method": "GET"}); |
|
|
|
let response = await fetch(url, {"method": "GET"}); |
|
|
|
// 返回页面内容
|
|
|
|
// 返回页面内容
|
|
|
|
let htmlStr = await response.text(); |
|
|
|
let htmlStr = await response.text(); |
|
|
|
// console.log(htmlStr)
|
|
|
|
console.log(htmlStr) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 页面返回cookie
|
|
|
|
// 页面返回cookie
|
|
|
@ -114,7 +153,7 @@ async function test() { |
|
|
|
|
|
|
|
|
|
|
|
let staticJs = fs.readFileSync('/home/liu/桌面/MO5zzCMcub4d.b4c45da.js'); |
|
|
|
let staticJs = fs.readFileSync('/home/liu/桌面/MO5zzCMcub4d.b4c45da.js'); |
|
|
|
|
|
|
|
|
|
|
|
loadPages(url, staticJs.toString('utf8'), htmlStr, cookies, "") |
|
|
|
await loadPages(url, staticJs.toString('utf8'), htmlStr, cookies, "") |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|