修改whatshub工单爬虫

This commit is contained in:
root
2026-06-29 04:54:41 +08:00
parent 6130125427
commit 9f2e904fab
14 changed files with 1254 additions and 147 deletions
+18 -2
View File
@@ -2,6 +2,21 @@
* Cloudflare / Turnstile 挑战页检测
*/
/**
* URL 是否处于 CF Managed Challenge 中间态(Whatshub 短链常见 __cf_chl_rt_tk
* @param {string} url
*/
function urlIndicatesCfChallenge(url) {
if (!url || typeof url !== 'string') {
return false;
}
return url.includes('__cf_chl_rt_tk')
|| url.includes('__cf_chl_tk')
|| url.includes('__cf_chl_f_tk')
|| url.includes('/cdn-cgi/challenge-platform')
|| url.includes('/cdn-cgi/challenge');
}
/**
* @typedef {Object} CloudflareState
* @property {boolean} blocked 是否处于 CF 挑战中
@@ -44,10 +59,10 @@ async function detectCloudflare(page) {
bodyHasJustAMoment: false,
}));
const urlChallenge = url.includes('/cdn-cgi/challenge-platform') || url.includes('/cdn-cgi/challenge');
const urlChallenge = urlIndicatesCfChallenge(url);
let challengeType = null;
if (domSignals.hasTurnstileInput || domSignals.hasTurnstileWidget) {
if (domSignals.hasTurnstileInput || domSignals.hasTurnstileWidget || url.includes('__cf_chl')) {
challengeType = 'turnstile';
} else if (urlChallenge || domSignals.titleHasJustAMoment || domSignals.bodyHasJustAMoment) {
challengeType = 'js_challenge';
@@ -94,4 +109,5 @@ async function isTurnstileSolved(page) {
module.exports = {
detectCloudflare,
isTurnstileSolved,
urlIndicatesCfChallenge,
};