From 929547657cc847da9abe3eafd7d52f997ade57b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E5=BF=97?= Date: Tue, 20 Jan 2026 15:18:09 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E5=96=84=E8=AF=B7=E6=B1=82=E5=A4=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controller/Crawler.php | 9 +++++++ app/service/CrawlerService.php | 26 ++++++++++++++++-- view/crawler/index.html | 48 ++++++++-------------------------- 3 files changed, 44 insertions(+), 39 deletions(-) diff --git a/app/controller/Crawler.php b/app/controller/Crawler.php index c3ab17f..a440170 100644 --- a/app/controller/Crawler.php +++ b/app/controller/Crawler.php @@ -64,10 +64,19 @@ class Crawler extends BaseController curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_TIMEOUT, 30); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10); + curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); + curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); + curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); curl_setopt($ch, CURLOPT_HTTPHEADER, [ + '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,en;q=0.8', + 'Accept-Encoding: gzip, deflate', + 'Cache-Control: no-cache', + 'Connection: keep-alive', 'Cookie: ' . $cookieString, 'User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36', 'Referer: http://gzrsks.oumakspt.com:62/tyzpwb/', + 'Upgrade-Insecure-Requests: 1', ]); $html = curl_exec($ch); diff --git a/app/service/CrawlerService.php b/app/service/CrawlerService.php index 95f3ac0..05e4317 100644 --- a/app/service/CrawlerService.php +++ b/app/service/CrawlerService.php @@ -29,9 +29,20 @@ class CrawlerService $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); + curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); + curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); + curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); curl_setopt($ch, CURLOPT_HTTPHEADER, [ - 'Cookie: ' . $cookieString, + 'Accept: application/json, text/javascript, */*; q=0.01', + 'Accept-Language: zh-CN,zh;q=0.9,en;q=0.8', + 'Accept-Encoding: gzip, deflate', + 'Cache-Control: no-cache', + 'Connection: keep-alive', 'Content-Type: application/x-www-form-urlencoded', + 'Cookie: ' . $cookieString, + 'User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36', + 'Referer: http://gzrsks.oumakspt.com:62/tyzpwb/', + 'X-Requested-With: XMLHttpRequest', ]); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query(['dsdm' => $dsdm])); @@ -76,9 +87,20 @@ class CrawlerService $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); + curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); + curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); + curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); curl_setopt($ch, CURLOPT_HTTPHEADER, [ - 'Cookie: ' . $cookieString, + 'Accept: application/json, text/javascript, */*; q=0.01', + 'Accept-Language: zh-CN,zh;q=0.9,en;q=0.8', + 'Accept-Encoding: gzip, deflate', + 'Cache-Control: no-cache', + 'Connection: keep-alive', 'Content-Type: application/x-www-form-urlencoded', + 'Cookie: ' . $cookieString, + 'User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36', + 'Referer: http://gzrsks.oumakspt.com:62/tyzpwb/', + 'X-Requested-With: XMLHttpRequest', ]); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query([ diff --git a/view/crawler/index.html b/view/crawler/index.html index a792230..5a90579 100644 --- a/view/crawler/index.html +++ b/view/crawler/index.html @@ -246,19 +246,13 @@
- 推荐直接填写,避免粘贴JSON出错 + 从浏览器开发者工具中复制JSESSIONID的值
- 推荐直接填写,避免粘贴JSON出错 -
- -
- - - 可选:若上面已填写两个字段,此处可留空;否则请按JSON格式填写完整Cookie + 从浏览器开发者工具中复制SERVERID的值
@@ -447,42 +441,22 @@ }); } - // 组装Cookie数据(支持单独填写和JSON) + // 组装Cookie数据 function buildCookiesPayload(messageContainerId) { - const raw = document.getElementById('cookies').value.trim(); const jsessionid = document.getElementById('cookie-jsessionid').value.trim(); const serverid = document.getElementById('cookie-serverid').value.trim(); - let cookies = { "请求 Cookie": {} }; - - if (raw) { - try { - const parsed = JSON.parse(raw); - cookies = parsed; - } catch (e) { - showMessage(messageContainerId, 'Cookie数据格式错误,请检查JSON格式', 'error'); - return null; - } - } - - // 确保存在“请求 Cookie”层级 - if (!cookies['请求 Cookie'] || typeof cookies['请求 Cookie'] !== 'object') { - cookies['请求 Cookie'] = {}; - } - - if (jsessionid) { - cookies['请求 Cookie']['JSESSIONID'] = jsessionid; - } - if (serverid) { - cookies['请求 Cookie']['SERVERID'] = serverid; - } - - if (Object.keys(cookies['请求 Cookie']).length === 0) { - showMessage(messageContainerId, '请填写Cookie数据', 'error'); + if (!jsessionid || !serverid) { + showMessage(messageContainerId, '请填写JSESSIONID和SERVERID', 'error'); return null; } - return cookies; + return { + "请求 Cookie": { + "JSESSIONID": jsessionid, + "SERVERID": serverid + } + }; } // 全选/取消全选