Commit 20e88d4a authored by hj's avatar hj

更新提交

parent 33a0a3db
...@@ -96,13 +96,13 @@ class CheMenuService ...@@ -96,13 +96,13 @@ class CheMenuService
$responseHtml = $this->apiService->getPage($pageUrl); $responseHtml = $this->apiService->getPage($pageUrl);
//file_put_contents('./test3.html', $responseHtml); //file_put_contents('./test3.html', $responseHtml);
if($responseHtml){ if($responseHtml){
if(preg_match('/<h2><span class=[\\\'|\"]caption-subject font-blue-sharp bold[\\\'|\"]>Sorry ! You visit too frequently, please complete validation[\s\S]*?</span></h2>/i', $responseHtml)){ if(preg_match('/<span[\s]*?class=[\\\'|\"]caption-subject font-blue-sharp bold[\\\'|\"]>Sorry ! You visit too frequently, please complete validation[\s\S]*?<\/span><\/h2>/i', $responseHtml)){
SimpleLogs::writeLog('遇到反爬系统', 'chemenu info', 'info'); SimpleLogs::writeLog('遇到反爬系统', 'chemenu info', 'info');
return true; return true;
} }
$productPageContent = []; $productPageContent = [];
SimpleLogs::writeLog('页面基础数据获取成功', 'chemenu info', 'info');
if(preg_match('/<div[\s]*?class=[\\\'|\"]products-content[\\\'|\"]>/i', $responseHtml)){ if(preg_match('/<div[\s]*?class=[\\\'|\"]products-content[\\\'|\"]>/i', $responseHtml)){
SimpleLogs::writeLog('页面基础数据获取成功', 'chemenu info', 'info');
$imageDivRegx = '/<div[\s]*?class=[\\\'|\"]product-image[\\\'|\"]>[\s\S]*?<img[\s]*?class=[\\\'|\"]big_img[\\\'|\"][\s]*?src[\s\S]*?[\\\'|\"](?<image>[\s\S]+?)[\\\'|\"]/i'; $imageDivRegx = '/<div[\s]*?class=[\\\'|\"]product-image[\\\'|\"]>[\s\S]*?<img[\s]*?class=[\\\'|\"]big_img[\\\'|\"][\s]*?src[\s\S]*?[\\\'|\"](?<image>[\s\S]+?)[\\\'|\"]/i';
preg_match($imageDivRegx, $responseHtml, $image); preg_match($imageDivRegx, $responseHtml, $image);
if($image && $image['image']){ if($image && $image['image']){
...@@ -164,6 +164,7 @@ class CheMenuService ...@@ -164,6 +164,7 @@ class CheMenuService
} }
} }
} }
SimpleLogs::writeLog('数据解析结束。数据:'.json_encode($productPageContent, JSON_UNESCAPED_UNICODE), 'chemenu info', 'info');
$this->apiService->saveProduct($productPageContent); $this->apiService->saveProduct($productPageContent);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment