复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37public function classdate(){ $find = thinkDb::table('classa')->field('id,folder,ClassBasicInfo')->select(); $arr = []; foreach ($find as $key => $value) { $arr[$key]['url'] = 'http://www.xxx.com/' . $value['folder']; $arr[$key]['id'] =$value['id']; } return $arr; } public function curl(){ set_time_limit(0); $ch = array(); $res = array(); $conn = array(); $html=[]; $urls =$this->classdate(); foreach ($urls as $key => $url) { $ch = curl_init($url['url']); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $result = curl_exec($ch); curl_close($ch); $html[$key]['id']= $url['id']; $html[$key]['title'] = preg_match('!<title>(.*?)</title>!i', $result, $matches) ? $matches[1] : ''; $html[$key]['keywords'] = preg_match('/<METAs+name="keywords"s+content="([wW]*?)"/si', $result, $matches) ? $matches[1] : ''; $html[$key]['desc'] = preg_match('/<METAs+name="description"s+content="([wW]*?)"/si', $result, $matches) ? $matches[1] : ''; $update = thinkDb::table('classa')->where('id', $url['id'])->update([ 'title'=>$html[$key]['title'], 'keywords' =>$html[$key]['keywords'], 'desc'=>$html[$key]['desc'], ]); } dump($html); }
最后
以上就是闪闪铃铛最近收集整理的关于采集指定页面的标题,关键字的全部内容,更多相关采集指定页面内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复