Commit 889256b8 authored by hj's avatar hj

更新提交

parent 29de768e
...@@ -30,10 +30,10 @@ class ChemSrcService ...@@ -30,10 +30,10 @@ class ChemSrcService
try{ try{
$responseHtml = $this->apiService->getCasWebInfo($cas); $responseHtml = $this->apiService->getCasWebInfo($cas);
if($responseHtml){ if($responseHtml){
$wuhuaList = [];
$wuhuaDivRegx = '/id=[\\\'|\"]wuHuaDiv[\\\'|\"]>(?<wuhuaHtml>[\s\S]+?)<div\s{0,}class=[\\\'|\"]cata-div row[\\\'|\"]/i'; $wuhuaDivRegx = '/id=[\\\'|\"]wuHuaDiv[\\\'|\"]>(?<wuhuaHtml>[\s\S]+?)<div\s{0,}class=[\\\'|\"]cata-div row[\\\'|\"]/i';
preg_match($wuhuaDivRegx, $responseHtml,$wuhuaHtml); preg_match($wuhuaDivRegx, $responseHtml,$wuhuaHtml);
if(!empty($wuhuaHtml)) { if(!empty($wuhuaHtml)) {
$wuhuaList = [];
$wuhuaDetailRegx = '/<th[\s\S]*?>(?<title>[\s\S]*?)<\/th>[\s\S]*?<td[\s\S]*?>(?<content>[\s\S]*?)<\/td>/i'; $wuhuaDetailRegx = '/<th[\s\S]*?>(?<title>[\s\S]*?)<\/th>[\s\S]*?<td[\s\S]*?>(?<content>[\s\S]*?)<\/td>/i';
preg_match_all($wuhuaDetailRegx, $wuhuaHtml['wuhuaHtml'],$wuhuaDetailList); preg_match_all($wuhuaDetailRegx, $wuhuaHtml['wuhuaHtml'],$wuhuaDetailList);
if(!empty($wuhuaDetailList)){ if(!empty($wuhuaDetailList)){
...@@ -41,7 +41,6 @@ class ChemSrcService ...@@ -41,7 +41,6 @@ class ChemSrcService
$wuhuaList[$title] = str_replace( " ", "", str_replace( "\r\n", "", $wuhuaDetailList['content'][$key])); $wuhuaList[$title] = str_replace( " ", "", str_replace( "\r\n", "", $wuhuaDetailList['content'][$key]));
} }
} }
}
if(!empty($wuhuaList)){ if(!empty($wuhuaList)){
$baikeMysql = DB::connection('baike_mysql'); $baikeMysql = DB::connection('baike_mysql');
$baikeMysql->table('tp_mol_wuhua') $baikeMysql->table('tp_mol_wuhua')
...@@ -52,6 +51,7 @@ class ChemSrcService ...@@ -52,6 +51,7 @@ class ChemSrcService
'content' => json_encode([$wuhuaList], JSON_UNESCAPED_UNICODE) 'content' => json_encode([$wuhuaList], JSON_UNESCAPED_UNICODE)
]); ]);
} }
}
return true; return true;
} }
}catch(\Throwable $exception){ }catch(\Throwable $exception){
......
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