正在显示
1 个修改的文件
包含
2 行增加
和
2 行删除
| @@ -188,13 +188,13 @@ class TranslateLogic extends BaseLogic | @@ -188,13 +188,13 @@ class TranslateLogic extends BaseLogic | ||
| 188 | // $contentData[] = $trimmedString; | 188 | // $contentData[] = $trimmedString; |
| 189 | // } | 189 | // } |
| 190 | $contentData = array_values($textContentArray); | 190 | $contentData = array_values($textContentArray); |
| 191 | - $pattern = '/<meta\s+([^>]*\s+)?name=[\'"](keywords|description)[\'"]([^>]*\s+)?content=[\'"]([^\'"]+)[\'"]([^>]*)?>/i'; // 匹配 name 为 "keywords" 或 "description" 的 meta 标签的正则表达式 | 191 | + $pattern = '/<meta\s+[^>]*name=[\'"](keywords|description)[\'"][^>]*content=[\'"]([^\'"]+)[\'"]>/i'; // 匹配 name 为 "keywords" 或 "description" 的 meta 标签的正则表达式 |
| 192 | $matches = array(); | 192 | $matches = array(); |
| 193 | preg_match_all($pattern, $strippedContent, $matches); | 193 | preg_match_all($pattern, $strippedContent, $matches); |
| 194 | $metaData = array(); | 194 | $metaData = array(); |
| 195 | @file_put_contents(storage_path('logs/lyh_error.log'), var_export($matches[2], true) . PHP_EOL, FILE_APPEND); | 195 | @file_put_contents(storage_path('logs/lyh_error.log'), var_export($matches[2], true) . PHP_EOL, FILE_APPEND); |
| 196 | foreach ($matches[2] as $index => $content) { | 196 | foreach ($matches[2] as $index => $content) { |
| 197 | - if(!empty($content)){ | 197 | + if(!empty(trim($content))){ |
| 198 | $metaData[] = $content; | 198 | $metaData[] = $content; |
| 199 | } | 199 | } |
| 200 | } | 200 | } |
-
请 注册 或 登录 后发表评论