0
$url = 'http://ecigm.com/bk/dt/index.php?1=1&page=5';
  //采集规则
        $reg  = [
            'detail_link' => ['.deanarticec>.deanarticer>.deanarticername>a', 'href'],
            //采集文章标题
            'title'       => ['.deanarticec>.deanarticer>.deanarticername>a', 'text'],
            'image'       => ['.deanarticec>.deanarticel>.atc>a>img', 'src'],
            'brief'       => ['.deanarticec>.deanarticersummary', 'text', '-a -.content_copyright -script'],
        ];
        $rang = '.deanartice>ul>li';

        dd(QueryList::get($url)->encoding('UTF-8','GBK')->rules($reg)->range($rang)->queryData());    // not work
//        dd(QueryList::get($url)->rules($reg)->range($rang)->queryData());    //work
2019-07-18 提问
1 个回答
1

这种情况一般是网页结构不规范引起的,可以尝试以下解决方法:

  • 采集到内容后,手动对采集到的结果进行转码
  • 自己手动获取到HTML源码后,然后对源码进行转码,然后再讲源码传给QueryList来抽取内容
  • 尝试调用removeHead()方法

撰写答案

推广链接