作者 刘锟

update

@@ -90,7 +90,7 @@ class HtmlCollect extends Command @@ -90,7 +90,7 @@ class HtmlCollect extends Command
90 90
91 //采集html页面,下载资源到本地并替换 91 //采集html页面,下载资源到本地并替换
92 try { 92 try {
93 - $html = curl_c('https://' . $collect_info->domain . $collect_info->route, false); 93 + $html = curl_code('https://' . $collect_info->domain . $collect_info->route, false);
94 if (strlen($html) < 4) { 94 if (strlen($html) < 4) {
95 95
96 if ($html == 404) { 96 if ($html == 404) {
@@ -202,6 +202,43 @@ if (!function_exists('curl_c')) { @@ -202,6 +202,43 @@ if (!function_exists('curl_c')) {
202 } 202 }
203 } 203 }
204 204
  205 +if (!function_exists('curl_code')) {
  206 + /**
  207 + * @param $url
  208 + * @param $is_array
  209 + * @return []
  210 + * @author Akun
  211 + * @date 2023/11/22 11:33
  212 + */
  213 + function curl_code($url,$is_array=true){
  214 + $header = array(
  215 + 'Expect:',
  216 + 'Content-Type: application/json; charset=utf-8'
  217 + );
  218 + $ch = curl_init($url);
  219 + curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  220 + curl_setopt($ch, CURLOPT_HEADER, false);
  221 + curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
  222 + curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.135 Safari/537.36 Edge/12.246');
  223 + curl_setopt($ch, CURLOPT_AUTOREFERER, true);
  224 + curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 120);
  225 + curl_setopt($ch, CURLOPT_TIMEOUT, 120);
  226 + curl_setopt($ch, CURLOPT_MAXREDIRS, 10);
  227 + curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
  228 + curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
  229 + curl_setopt($ch, CURLOPT_SSLVERSION, 'all');
  230 + curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
  231 + $content = curl_exec($ch);
  232 + $http_code = curl_getinfo($ch,CURLINFO_HTTP_CODE);
  233 + curl_close($ch);
  234 + if($http_code == 200){
  235 + return $is_array ? json_decode($content, true) : $content;
  236 + }else{
  237 + return $http_code;
  238 + }
  239 + }
  240 +}
  241 +
205 242
206 if (!function_exists('_get_child')) { 243 if (!function_exists('_get_child')) {
207 /** 244 /**