|
...
|
...
|
@@ -29,6 +29,8 @@ class ProofreadingController extends BaseController |
|
|
|
$list = $proofreadingModel->list(['url'=>$this->param['url'],'language_id'=>$this->param['language_id'],'type'=>1],'text',['text','translate']);
|
|
|
|
//获取当前URl的所有文本内容
|
|
|
|
$new_list = $this->getUrlRead($this->param['url']);
|
|
|
|
var_dump($new_list);
|
|
|
|
die();
|
|
|
|
if(empty($list)){
|
|
|
|
$data = [];
|
|
|
|
$translate_list = Translate::tran($new_list, $countryInfo['alias']);
|
|
...
|
...
|
@@ -50,10 +52,6 @@ class ProofreadingController extends BaseController |
|
|
|
];
|
|
|
|
}
|
|
|
|
$arr2 = array_diff($new_list, $old_list);
|
|
|
|
var_dump($new_list);
|
|
|
|
var_dump($old_list);
|
|
|
|
var_dump($arr2);
|
|
|
|
die();
|
|
|
|
if(!empty($arr2)){
|
|
|
|
$translate_list = Translate::tran($arr2, $countryInfo['alias']);
|
|
|
|
foreach ($arr2 as $k1=>$v1){
|
|
...
|
...
|
@@ -160,17 +158,21 @@ class ProofreadingController extends BaseController |
|
|
|
$strippedContent = preg_replace($pattern, '', $strippedContent); // 删除 `<link>` 标签
|
|
|
|
$pattern = '/<footer\b[^>]*>(.*?)<\/footer>/s'; // 定义匹配`<script>`标签及其内容的正则表达式
|
|
|
|
$strippedContent = preg_replace($pattern, '', $strippedContent); // 删除`<script>`标签及其内容
|
|
|
|
$pattern = '/>([^<]+)</'; // 定义匹配中间内容不是标签的正则表达式
|
|
|
|
$matches = array();
|
|
|
|
preg_match_all($pattern, $strippedContent, $matches);
|
|
|
|
$textContentArray = array_filter($matches[1], function($item) {
|
|
|
|
$item = str_replace("\n", "", $item);
|
|
|
|
return !empty(trim($item));
|
|
|
|
});
|
|
|
|
$textContentArray = array_values($textContentArray);
|
|
|
|
$uniqueArray = array_unique($textContentArray);
|
|
|
|
$textContentArray = array_values($uniqueArray);
|
|
|
|
return $textContentArray;
|
|
|
|
// $pattern = '/>([^<]+)</'; // 定义匹配中间内容不是标签的正则表达式
|
|
|
|
// $matches = array();
|
|
|
|
// preg_match_all($pattern, $strippedContent, $matches);
|
|
|
|
// $textContentArray = array_filter($matches[1], function($item) {
|
|
|
|
// $item = str_replace("\n", "", $item);
|
|
|
|
// return !empty(trim($item));
|
|
|
|
// });
|
|
|
|
$pattern = '/<(\w+)[^>]*>(.*?)<\/\1>/s'; // Define the regular expression pattern
|
|
|
|
preg_match_all($pattern, $strippedContent, $matches); // Match all tags and their content
|
|
|
|
|
|
|
|
$tagContentArray = $matches[2]; // Extract the content part from the matches array
|
|
|
|
// $textContentArray = array_values($textContentArray);
|
|
|
|
// $uniqueArray = array_unique($textContentArray);
|
|
|
|
// $textContentArray = array_values($uniqueArray);
|
|
|
|
return $tagContentArray;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
...
|
...
|
|