This commit is contained in:
杨志
2026-01-21 08:53:45 +08:00
parent f9c34127c7
commit a962e06a18
14 changed files with 574 additions and 222 deletions

View File

@@ -9,23 +9,29 @@ namespace app\service;
*/
class CrawlerService
{
/**
* 基础URL域名和端口
*/
private const BASE_URL = 'http://gzrsks.oumakspt.com:62';
/**
* 应用路径
*/
private const APP_PATH = '/tyzpwb';
/**
* 获取基础URL域名和端口
* @return string
*/
private function getBaseUrlHost(): string
{
// 从配置服务获取BASE_URL
$configService = new \app\service\ConfigService();
return $configService->getBaseUrl();
}
/**
* 获取完整基础URL包含应用路径
* @return string
*/
public function getBaseUrl(): string
{
return self::BASE_URL . self::APP_PATH;
return $this->getBaseUrlHost() . self::APP_PATH;
}
/**
@@ -88,7 +94,7 @@ class CrawlerService
// Origin
if ($isFirefox) {
$headers[] = 'Origin: ' . self::BASE_URL;
$headers[] = 'Origin: ' . $this->getBaseUrlHost();
} elseif ($origin !== null) {
$headers[] = 'Origin: ' . $origin;
}
@@ -174,7 +180,7 @@ class CrawlerService
$cookieString = $this->buildCookieString($cookies);
$referer = $baseUrl . '/stuchooseexam/selectPosition.htm';
$origin = self::BASE_URL;
$origin = $this->getBaseUrlHost();
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);