|
@@ -301,29 +301,20 @@ class IndexController extends HomeBaseController
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
public function test(){
|
|
public function test(){
|
|
|
|
|
+ return false;
|
|
|
set_time_limit(0);
|
|
set_time_limit(0);
|
|
|
$content = file_get_contents('./logs/168.html');
|
|
$content = file_get_contents('./logs/168.html');
|
|
|
// $content = file_get_contents('http://www.1688cypt.com/');
|
|
// $content = file_get_contents('http://www.1688cypt.com/');
|
|
|
-// $content = '<div>dfg<img data-src="https://www.1688cypt.com/upload/admin/20200620/75aed24b3651e9991fde12830b9a8000.png?v=1" width="174" height="130" alt="洋葱数学教育" onerror="imageError(this)"></div><div>dfg<img src="https://www.1688cypt.com/upload/admin/20200619/75aed24b3651e9991fde12830b9a8000.png?v=1" width="174" height="130" alt="洋葱数学教育" onerror="imageError(this)"></div>';
|
|
|
|
|
|
|
+
|
|
|
preg_match_all('/(href|src|data-src)=([\"|\']?)([^\"\'>]+.(jpg|JPG|jpeg|JPEG|gif|GIF|png|PNG))/i', $content, $result);
|
|
preg_match_all('/(href|src|data-src)=([\"|\']?)([^\"\'>]+.(jpg|JPG|jpeg|JPEG|gif|GIF|png|PNG))/i', $content, $result);
|
|
|
-// var_dump($result);
|
|
|
|
|
$imgs = isset($result[3])? $result[3] : [];
|
|
$imgs = isset($result[3])? $result[3] : [];
|
|
|
-// $img = 'https://www.1688cypt.com/upload/admin/20200619/75aed24b3651e9991fde12830b9a8000.png';
|
|
|
|
|
-
|
|
|
|
|
- /*$paths = parse_url($img);
|
|
|
|
|
- var_dump($paths);
|
|
|
|
|
- $path = isset($paths['path'])? dirname($paths['path']) : '';
|
|
|
|
|
- var_dump($path);
|
|
|
|
|
- exit;*/
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
foreach ($imgs as $img){
|
|
foreach ($imgs as $img){
|
|
|
$img = str_replace('https:','http:', $img);
|
|
$img = str_replace('https:','http:', $img);
|
|
|
$paths = parse_url($img);
|
|
$paths = parse_url($img);
|
|
|
$filename = isset($paths['path'])? $paths['path'] : '';
|
|
$filename = isset($paths['path'])? $paths['path'] : '';
|
|
|
- $path = $filename? './news'.dirname($filename) : '';
|
|
|
|
|
|
|
+ $path = $filename? './xm13'.dirname($filename) : '';
|
|
|
echo '抓取到图片:'."<br>";
|
|
echo '抓取到图片:'."<br>";
|
|
|
- if($filename && !file_exists('./news'.$filename) ){
|
|
|
|
|
|
|
+ if($filename && !file_exists('./xm13'.$filename) ){
|
|
|
$content = file_get_contents($img);
|
|
$content = file_get_contents($img);
|
|
|
if($content){
|
|
if($content){
|
|
|
if(!is_dir($path)){
|
|
if(!is_dir($path)){
|
|
@@ -331,7 +322,7 @@ class IndexController extends HomeBaseController
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
echo "下载保存图片:".'./imgs'.$filename."<br>";
|
|
echo "下载保存图片:".'./imgs'.$filename."<br>";
|
|
|
- file_put_contents('./news'.$filename, $content);
|
|
|
|
|
|
|
+ // file_put_contents('./xm13'.$filename, $content);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|