update
This commit is contained in:
@@ -17,15 +17,30 @@ class CrawlerService
|
||||
/**
|
||||
* 获取职位树数据
|
||||
* @param string $dsdm 地区代码
|
||||
* @param string $examid 考试ID
|
||||
* @param string $bmid 部门ID
|
||||
* @param string $userid 用户ID
|
||||
* @param string $aa 时间戳(必须与selectPosition页一致)
|
||||
* @param array $cookies Cookie数据
|
||||
* @return array
|
||||
*/
|
||||
public function getPositionTree(string $dsdm, array $cookies): array
|
||||
public function getPositionTree(string $dsdm, string $examid, string $bmid, string $userid, string $aa, array $cookies): array
|
||||
{
|
||||
$url = $this->baseUrl . '/tree/getPositionTree.htm';
|
||||
|
||||
$cookieString = $this->buildCookieString($cookies);
|
||||
|
||||
// 构建Referer URL(包含完整参数)
|
||||
$refererUrl = "http://gzrsks.oumakspt.com:62/tyzpwb/stuchooseexam/selectPosition.htm?examstupid=1015&userid={$userid}&bmid={$bmid}&examid={$examid}&aa={$aa}";
|
||||
|
||||
// 构建POST参数
|
||||
$postData = [
|
||||
'examid' => $examid,
|
||||
'bmid' => $bmid,
|
||||
'userid' => $userid,
|
||||
'dsdm' => $dsdm
|
||||
];
|
||||
|
||||
$ch = curl_init();
|
||||
curl_setopt($ch, CURLOPT_URL, $url);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
@@ -37,17 +52,18 @@ class CrawlerService
|
||||
'Accept: text/plain, */*',
|
||||
'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',
|
||||
'Pragma: no-cache',
|
||||
'Cache-Control: no-cache',
|
||||
'Connection: keep-alive',
|
||||
'Content-Type: application/x-www-form-urlencoded; charset=UTF-8',
|
||||
'Content-Type: application/x-www-form-urlencoded',
|
||||
'Cookie: ' . $cookieString,
|
||||
'Origin: http://gzrsks.oumakspt.com:62',
|
||||
'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/143.0.0.0 Safari/537.36',
|
||||
'Referer: http://gzrsks.oumakspt.com:62/tyzpwb/stuchooseexam/selectPosition.htm',
|
||||
'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:147.0) Gecko/20100101 Firefox/147.0',
|
||||
'Referer: ' . $refererUrl,
|
||||
'X-Requested-With: XMLHttpRequest',
|
||||
]);
|
||||
curl_setopt($ch, CURLOPT_POST, true);
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query(['dsdm' => $dsdm]));
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($postData));
|
||||
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
|
||||
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user