Commit 5268b332 authored by hj's avatar hj

更新提交

parent a24e0f3c
...@@ -59,15 +59,15 @@ class CheMenuApiService extends PlatformAbstractService ...@@ -59,15 +59,15 @@ class CheMenuApiService extends PlatformAbstractService
try{ try{
$response = $this->getPostClient($this->yybaoApiUrl.'/webpage/chemenu/saveProduct', $response = $this->getPostClient($this->yybaoApiUrl.'/webpage/chemenu/saveProduct',
[ [
'productName' => $productContent['productName'], 'productName' => $productContent['productName'] ?? '',
'iupac' => $productContent['IUPAC'], 'iupac' => $productContent['IUPAC'] ?? '',
'image' => $productContent['image'], 'categoryName' => $productContent['categoryName'] ?? '',
'image' => $productContent['image'] ?? '',
'casInfo' => json_encode($productContent['casInfo']), 'casInfo' => json_encode($productContent['casInfo']),
'productList' => json_encode($productContent['productList']) 'productList' => json_encode($productContent['productList'])
], []); ], []);
return $this->returnResponse($response); return $this->returnResponse($response);
}catch(\Throwable $exception){ }catch(\Throwable $exception){
dd($exception->getMessage());
if(preg_match('/\{(?<response>[\s\S]*?)\}/i', $exception->getMessage(), $response)){ if(preg_match('/\{(?<response>[\s\S]*?)\}/i', $exception->getMessage(), $response)){
$response = json_decode('{'.$response['response'].'}', true); $response = json_decode('{'.$response['response'].'}', true);
if($response && $response['status'] == 429){ if($response && $response['status'] == 429){
......
...@@ -140,6 +140,14 @@ class CheMenuService ...@@ -140,6 +140,14 @@ class CheMenuService
} }
$productPageContent = []; $productPageContent = [];
SimpleLogs::writeLog('页面基础数据获取成功', 'chemenu info', 'info'); SimpleLogs::writeLog('页面基础数据获取成功', 'chemenu info', 'info');
//分类
$productPageContent['categoryName'] = '';
if(preg_match('/<li>[\s\S]*Category:[\s\S]*?<a[\s\S]*?>(?<categoryName>[\s\S]*?)<\/a><\/li>/i', $responseHtml, $navBar)){
$productPageContent['categoryName'] = $navBar['categoryName'];
}
$productPageContent['image'] = '';
if(preg_match('/<div[\s]*?class=[\\\'|\"]products-content[\\\'|\"]>/i', $responseHtml)){ if(preg_match('/<div[\s]*?class=[\\\'|\"]products-content[\\\'|\"]>/i', $responseHtml)){
$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);
...@@ -164,6 +172,7 @@ class CheMenuService ...@@ -164,6 +172,7 @@ class CheMenuService
} }
} }
$productPageContent['casInfo'] = [];
$chemicalInfoDivRegx = '/<div[\s]*?class=[\\\'|\"]col-md-6 col-sm-12[\\\'|\"]>(?<chemicalInfoDiv>[\s\S]+?)<\/div>/i'; $chemicalInfoDivRegx = '/<div[\s]*?class=[\\\'|\"]col-md-6 col-sm-12[\\\'|\"]>(?<chemicalInfoDiv>[\s\S]+?)<\/div>/i';
preg_match_all($chemicalInfoDivRegx, $responseHtml, $chemicalInfoDiv); preg_match_all($chemicalInfoDivRegx, $responseHtml, $chemicalInfoDiv);
if($chemicalInfoDiv){ if($chemicalInfoDiv){
......
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