Update index.js
Browse files
index.js
CHANGED
@@ -64,12 +64,16 @@ app.get('/*', async (req, res) => {
|
|
64 |
|
65 |
// 判断访问路径
|
66 |
if (req.path === '/html') {
|
67 |
-
res.set('Content-Type', 'text/
|
68 |
res.send(result.htmlContent); // 发送 htmlContent 的纯文本响应
|
69 |
} else if (req.path === '/core') {
|
70 |
-
|
|
|
71 |
if (coreContent) {
|
72 |
-
|
|
|
|
|
|
|
73 |
res.set('Content-Type', 'text/plain');
|
74 |
res.send(extractedString); // 发送提取后的字符串
|
75 |
} else {
|
|
|
64 |
|
65 |
// 判断访问路径
|
66 |
if (req.path === '/html') {
|
67 |
+
res.set('Content-Type', 'text/html');
|
68 |
res.send(result.htmlContent); // 发送 htmlContent 的纯文本响应
|
69 |
} else if (req.path === '/core') {
|
70 |
+
// 先找到包含前后字符的字符串
|
71 |
+
const coreContent = result.htmlContent.match(/\[CDATA\[(\(function\(n,t\)\{onload=function\(\)\{_G\.BPT=new Date;n&&n\(\)\{.*?\/\/\]\]\//s);
|
72 |
if (coreContent) {
|
73 |
+
// 删除掉不需要的部分
|
74 |
+
let extractedString = coreContent[0];
|
75 |
+
extractedString = extractedString.replace('[CDATA[', '').replace('//]]', '');
|
76 |
+
extractedString = extractedString.replace(/https:\/\/r\.bing\.com\/rp\//g, 'https://sokwith-proxybing.hf.space/rp/');
|
77 |
res.set('Content-Type', 'text/plain');
|
78 |
res.send(extractedString); // 发送提取后的字符串
|
79 |
} else {
|