-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathpachong.php
62 lines (49 loc) · 1.47 KB
/
pachong.php
1
<?php/** * Created by PhpStorm. * User: chentao * Date: 2019/10/29 * Time: 5:20 PM *///const URL = "http://www.punimaitv.com";const URL = "http://www.jzw110.com";//const URL = "http://www.jinyizhen.cc";getSource(URL);function getSource($url){ $file_content = file_get_contents($url);// 获取资源地址 preg_match_all('/href=([\"\'])([^\"|\'])+(html)/', $file_content, $content);//$content = preg_replace("/[\t\n\r]+/", "", $content);//echo "当前url地址: $url <br>";//var_dump($content[0]);die; $saveLink = []; $findLink = array_unique($content[0]);//var_dump($findLink);die; foreach ($findLink as $link) { if (strpos($link, 'http')) { $saveLink[] = $newLink = str_replace('href="', '', $link); } else { $saveLink[] = $newLink = URL . str_replace('href="', '', $link); } }//var_dump($saveLink);die; $key = "punimai"; $key_linked = "punimai_end"; $redis = new Redis(); $redis->connect('127.0.0.1', 6379); //获取并保存视频地址 preg_match_all('/http(s)?:\/\/(.)+\.mp4/', $file_content, $source); if (count($source[0])) { $redis->sAddArray('video_' . URL, $source[0]); } //保存连接 $res = $redis->sAddArray($key, $saveLink); echo $res . "\t"; if ($res) { foreach ($saveLink as $item) {// echo $item."<br>"; if ($redis->sAdd($key_linked, $item)) getSource($item);//爬取未扫描连接 } }}