本人使用PHP的cul扩展加querlist类库写的爬虫程序加thinkphp8

        #随机成三千个五位数的不重复数字
          $arr = [];
        for ($i = 1; $i <= 3000; $i++) {
            $arr[] = rand(10000, 99999);
            $arr = array_unique($arr);
            if (count($arr) == 3000) {
                break;
            }
        }

foreach ($arr as $k=>$vs){
    //删除视频标题重复出现过两次的数据
    $data = Db::name('hp')->field('spbt')->group('spbt')->having('count(spbt)>1')->select();
    foreach ($data as $k => $v) {
        Db::name('hp')->where('spbt', $v['spbt'])->limit(1)->delete();
    }
    $url = 'https://ht77gg.xyz:9527/vod/details/' . $vs;
    //使用cul扩展
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); // 获取数据返回
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); // 跳过证书检查
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); // 从证书中检查SSL加密算法是否存在
    //设置字符集utf-8
    curl_setopt($ch, CURLOPT_ENCODING, 'utf-8');
    $html = curl_exec($ch);
    curl_close($ch);
    #querlist获取<input type="text" value="https://cdn1.hongtaocdn3.com/video/m3u8/202307/10/baa46dea4414/baa46dea4414.mp4" class="form-control" readonly="">里面的内容
    $matches = QueryList::html($html)->find('input')->attrs('value')->all();
    $视频链接地址 = @$matches[1];
    #正则匹配<div class="vod-hits"><i class="zicon zicon-eye"></i>122.3w+</div>的播放量
    preg_match('/<div class="vod-hits"><i class="zicon zicon-eye"><\/i>(.*?)<\/div>/', $html, $matches);
    $视频的播放量 = @$matches[1];
    #获取<h1>里面的内容
    $matches = QueryList::html($html)->find('h1')->texts()->all();
    $视频标题 = @$matches[0];
    #把这三个数据装到新的数组里面
    $arr = ['spbt' => $视频标题, 'spdz' => $视频链接地址, 'spbfl' => $视频的播放量];
    #如果没有spbfl等于null就跳过
    if ($arr['spbfl'] == null){
        continue;
    }
    Db::name('hp')->insert($arr);
  • 5
    点赞
  • 10
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

qq_57952822

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值