Commit fb335397 authored by hj's avatar hj

更新提交

parent 5cababe4
......@@ -91,11 +91,18 @@ class CheMenuService
{
try{
$pageUrl = $url['url'];
SimpleLogs::writeLog('开始抓取'.$pageUrl.'页面数据', 'chemenu info', 'info');
sleep(2);
$responseHtml = $this->apiService->getPage($pageUrl);
//file_put_contents('./test3.html', $responseHtml);
if($responseHtml){
if(preg_match('/<h2><span class=[\\\'|\"]caption-subject font-blue-sharp bold[\\\'|\"]>Sorry ! You visit too frequently, please complete validation&nbsp;&nbsp;-&nbsp;&nbsp;step1.</span></h2>/i', $responseHtml)){
SimpleLogs::writeLog('遇到反爬系统', 'chemenu info', 'info');
return true;
}
$productPageContent = [];
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';
preg_match($imageDivRegx, $responseHtml, $image);
if($image && $image['image']){
......
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