采集
来源:互联网 发布:amazfit华米手表 知乎 编辑:程序博客网 时间:2024/04/28 20:15
header("content-type:text/html;charset=utf-8");set_time_limit(0);$url='http://sports.sohu.com/nba.shtml';$str=file_get_contents($url);$str=iconv("GBK","utf-8",$str);//echo $str;$reg='#<div style="HEIGHT: 290px; OVERFLOW: hidden" id="columnID" class="heavyColumn">.*<a onFocus="undefined" href="http://sports.sohu.com/s2016/7265/s460940033/" target="_blank">#isU';preg_match($reg,$str,$arr);//var_dump($arr);//标题$reg2='#<h4><a onFocus="undefined" title="" href="http://sports.sohu.com/s2016/7265/.*/" target="_blank">(.*)</a></h4>#isU';preg_match_all($reg2,$arr[0],$data1);//var_dump($data1);//内容$reg3='#<p>(.*)<a#isU';preg_match_all($reg3,$arr[0],$data2);//var_dump($data2);$pdo=new PDO('mysql:host=localhost;dbname=test','root','root');$pdo->exec("set names utf8");for($i=0;$i<count($data1[1]);$i++){ $title=$data1[1][$i]; $content=$data2[1][$i]; $sql="insert into nba (title,content) VALUES ('$title','$content')"; $pdo->exec($sql);}//图片$reg4='#<img alt="NBA" src="(.*)" border="0" height="100" width="100"></a>#isU';preg_match_all($reg4,$arr[0],$data3);//var_dump($data3);foreach($data3[1] as $v){ $path=file_get_contents($v); $ext=substr($v,strrpos($v,'.')); $file_name='img/'.time().rand(1000,9999).$ext; file_put_contents($file_name,$path);}
0 0
- 采集
- 采集
- 采集
- 采集
- 采集
- 采集
- 采集
- 采集
- 采集
- 采集
- 采集
- 采集与防采集
- 视频采集
- 采集程序
- c#采集
- 火车头采集
- 采集 利器
- 采集方法
- 主板芯片组与内存映射
- SegmentFault 技术周刊 Vol.16 - 浅入浅出 JavaScript 函数式编程
- Android Listview item向左滑动 显示菜单(仿QQ滑动)
- 使用combobox进行模糊查询
- activity 获取 rootView 设置 backGroundColor
- 采集
- iframe自适应子页高度
- Shell - 20
- 百度echarts自定义主题使用
- php 读取txt文件中的内容,转换成数组
- Mysql随机取样——ORDER BY RAND()优化
- 在使用AS过程中遇到的R文件报错(自己亲身经历)
- 混合式开发中表单input file不生效(在安卓端)
- 火灾疏散实时信息系统(演习)