diff --git a/app/controller/Crawler.php b/app/controller/Crawler.php index a440170..8fa2a12 100644 --- a/app/controller/Crawler.php +++ b/app/controller/Crawler.php @@ -56,9 +56,12 @@ class Crawler extends BaseController $cookieString = $this->buildCookieString($cookies); - // 构建URL获取HTML + // 构建URL获取HTML - 使用GET请求 $url = "http://gzrsks.oumakspt.com:62/tyzpwb/stuchooseexam/selectPosition.htm?examstupid=1015&userid={$userid}&bmid={$bmid}&examid={$examid}&aa=" . time() . '000'; + // 构建Referer URL(模拟从createbmpdf.htm页面跳转过来) + $refererUrl = "http://gzrsks.oumakspt.com:62/tyzpwb/stubm/createbmpdf.htm?userid={$userid}&bmid={$bmid}&examid={$examid}&jsessionid=&mydepid=&dqssds="; + $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); @@ -67,15 +70,15 @@ class Crawler extends BaseController curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); + curl_setopt($ch, CURLOPT_ENCODING, ''); // 自动处理gzip编码 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: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8', + 'Accept-Language: zh-CN,zh;q=0.9,zh-TW;q=0.8,zh-HK;q=0.7,en-US;q=0.6,en;q=0.5', '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/', + 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:147.0) Gecko/20100101 Firefox/147.0', + 'Referer: ' . $refererUrl, 'Upgrade-Insecure-Requests: 1', ]);