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,16 +41,16 @@ class ChemSrcService ...@@ -41,16 +41,16 @@ 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') ->updateOrInsert([
->updateOrInsert([ 'cas' => $cas
'cas' => $cas ], [
], [ 'mol_id' => $molId,
'mol_id' => $molId, 'content' => json_encode([$wuhuaList], JSON_UNESCAPED_UNICODE)
'content' => json_encode([$wuhuaList], JSON_UNESCAPED_UNICODE) ]);
]); }
} }
return true; return true;
} }
......
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