正在显示
3 个修改的文件
包含
27 行增加
和
31 行删除
| @@ -201,13 +201,13 @@ class ProjectController extends BaseController | @@ -201,13 +201,13 @@ class ProjectController extends BaseController | ||
| 201 | */ | 201 | */ |
| 202 | public function searchChannel(&$query){ | 202 | public function searchChannel(&$query){ |
| 203 | if(isset($this->map['zone_id']) && !empty($this->map['zone_id'])){ | 203 | if(isset($this->map['zone_id']) && !empty($this->map['zone_id'])){ |
| 204 | - $query->where('gl_project.channel','like','%"zone_id": "'.$this->map['channel_id'].'"%'); | 204 | + $query->where('gl_project.channel','like','%"zone_id": "'.$this->map['zone_id'].'"%'); |
| 205 | } | 205 | } |
| 206 | if(isset($this->map['channel_id']) && !empty($this->map['channel_id'])){ | 206 | if(isset($this->map['channel_id']) && !empty($this->map['channel_id'])){ |
| 207 | $query->where('gl_project.channel','like','%"channel_id": "'.$this->map['channel_id'].'"%'); | 207 | $query->where('gl_project.channel','like','%"channel_id": "'.$this->map['channel_id'].'"%'); |
| 208 | } | 208 | } |
| 209 | if(isset($this->map['user_id']) && !empty($this->map['user_id'])){ | 209 | if(isset($this->map['user_id']) && !empty($this->map['user_id'])){ |
| 210 | - $query->where('gl_project.channel','like','%"user_id": "'.$this->map['channel_id'].'"%'); | 210 | + $query->where('gl_project.channel','like','%"user_id": "'.$this->map['user_id'].'"%'); |
| 211 | } | 211 | } |
| 212 | return $query; | 212 | return $query; |
| 213 | } | 213 | } |
| @@ -301,31 +301,5 @@ class LoginController extends BaseController | @@ -301,31 +301,5 @@ class LoginController extends BaseController | ||
| 301 | } | 301 | } |
| 302 | 302 | ||
| 303 | public function ceshi(){ | 303 | public function ceshi(){ |
| 304 | - $url = 'https://demo.globalso.site/'; | ||
| 305 | - $contextOptions = [ | ||
| 306 | - 'ssl' => [ | ||
| 307 | - 'verify_peer' => false, | ||
| 308 | - 'verify_peer_name' => false, | ||
| 309 | - ], | ||
| 310 | - ]; | ||
| 311 | - $context = stream_context_create($contextOptions); | ||
| 312 | - $sourceCode = file_get_contents($url, false, $context); | ||
| 313 | - $pattern = '/<style\b[^>]*>(.*?)<\/style>/s'; // 定义匹配`<style>`标签及其内容的正则表达式 | ||
| 314 | - $strippedContent = preg_replace($pattern, '', $sourceCode); // 删除`<style>`标签及其内容 | ||
| 315 | - $pattern = '/<script\b[^>]*>(.*?)<\/script>/s'; // 定义匹配`<script>`标签及其内容的正则表达式 | ||
| 316 | - $strippedContent = preg_replace($pattern, '', $strippedContent); // 删除`<script>`标签及其内容 | ||
| 317 | - $pattern = '/<link\b[^>]*>/'; // 定义匹配 `<link>` 标签的正则表达式 | ||
| 318 | - $strippedContent = preg_replace($pattern, '', $strippedContent); // 删除 `<link>` 标签 | ||
| 319 | - $pattern = '/<footer\b[^>]*>(.*?)<\/footer>/s'; // 定义匹配`<script>`标签及其内容的正则表达式 | ||
| 320 | - $strippedContent = preg_replace($pattern, '', $strippedContent); // 删除`<script>`标签及其内容 | ||
| 321 | - $pattern = '/>([^<]+)</'; // 定义匹配中间内容不是标签的正则表达式 | ||
| 322 | - $matches = array(); | ||
| 323 | - preg_match_all($pattern, $strippedContent, $matches); | ||
| 324 | - $textContentArray = array_filter($matches[1], function($item) { | ||
| 325 | - return !empty(trim($item)); | ||
| 326 | - }); | ||
| 327 | - $textContentArray = array_values($textContentArray); | ||
| 328 | - $uniqueArray = array_unique($textContentArray); | ||
| 329 | - var_dump($uniqueArray); | ||
| 330 | } | 304 | } |
| 331 | } | 305 | } |
| @@ -60,8 +60,30 @@ class ProofreadingController extends BaseController | @@ -60,8 +60,30 @@ class ProofreadingController extends BaseController | ||
| 60 | * @time :2023/11/22 10:02 | 60 | * @time :2023/11/22 10:02 |
| 61 | */ | 61 | */ |
| 62 | public function getUrlRead($url){ | 62 | public function getUrlRead($url){ |
| 63 | - $sourceCode = file_get_contents($url); | ||
| 64 | - $strippedContent = strip_tags($sourceCode); // 删除所有HTML标签 | ||
| 65 | - var_dump($strippedContent); | 63 | + $contextOptions = [ |
| 64 | + 'ssl' => [ | ||
| 65 | + 'verify_peer' => false, | ||
| 66 | + 'verify_peer_name' => false, | ||
| 67 | + ], | ||
| 68 | + ]; | ||
| 69 | + $context = stream_context_create($contextOptions); | ||
| 70 | + $sourceCode = file_get_contents($url, false, $context); | ||
| 71 | + $pattern = '/<style\b[^>]*>(.*?)<\/style>/s'; // 定义匹配`<style>`标签及其内容的正则表达式 | ||
| 72 | + $strippedContent = preg_replace($pattern, '', $sourceCode); // 删除`<style>`标签及其内容 | ||
| 73 | + $pattern = '/<script\b[^>]*>(.*?)<\/script>/s'; // 定义匹配`<script>`标签及其内容的正则表达式 | ||
| 74 | + $strippedContent = preg_replace($pattern, '', $strippedContent); // 删除`<script>`标签及其内容 | ||
| 75 | + $pattern = '/<link\b[^>]*>/'; // 定义匹配 `<link>` 标签的正则表达式 | ||
| 76 | + $strippedContent = preg_replace($pattern, '', $strippedContent); // 删除 `<link>` 标签 | ||
| 77 | + $pattern = '/<footer\b[^>]*>(.*?)<\/footer>/s'; // 定义匹配`<script>`标签及其内容的正则表达式 | ||
| 78 | + $strippedContent = preg_replace($pattern, '', $strippedContent); // 删除`<script>`标签及其内容 | ||
| 79 | + $pattern = '/>([^<]+)</'; // 定义匹配中间内容不是标签的正则表达式 | ||
| 80 | + $matches = array(); | ||
| 81 | + preg_match_all($pattern, $strippedContent, $matches); | ||
| 82 | + $textContentArray = array_filter($matches[1], function($item) { | ||
| 83 | + return !empty(trim($item)); | ||
| 84 | + }); | ||
| 85 | + $textContentArray = array_values($textContentArray); | ||
| 86 | + $uniqueArray = array_unique($textContentArray); | ||
| 87 | + return $this->success($uniqueArray); | ||
| 66 | } | 88 | } |
| 67 | } | 89 | } |
-
请 注册 或 登录 后发表评论