php文章内容抓取
程序员文章站
2022-05-18 09:34:21
...
求大神帮忙抓取这个网页http://sports.sohu.com/zhongchao.shtml的排行榜部分的数据(包括积分榜和射手榜)
/isU', $s, $m);print_r(preg_grep('/名次/', $m[0]));
回复讨论(解决方案)
抓取 研究研究 phpquery
$url = 'http://sports.sohu.com/zhongchao.shtml';$s = file_get_contents($url);preg_match_all('/(?)\s
Array( [2] =>
名次 | 球队 | 场次 | 积分 | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
01 | 广州恒大 | 20 | 45 | ||||||||||||||||||||
02 | 北京国安 | ......接下来自己做||||||||||||||||||||||
(.+?)\s* | (.+?)\s* | (\d+)\s* | (.+?)\s*/i',$str,$match1);foreach($match1 as $k=>$v){ if($k!=0){ foreach($v as $k1=>$v1){ if($k1";print_r($jifen);print_r($sheshou);echo "";/*Array( [1] => Array ( [0] => 01 [1] => 02 [2] => 03 [3] => 04 [4] => 05 [5] => 06 [6] => 07 [7] => 08 [8] => 09 [9] => 10 [10] => 11 [11] => 12 [12] => 13 [13] => 14 [14] => 15 [15] => 16 ) [2] => Array ( [0] => 广州恒大 [1] => 北京国安 [2] => 广州富力 [3] => 上海东亚 [4] => 贵州茅台 [5] => 山东鲁能 [6] => 天津泰达 [7] => 江苏舜天 [8] => 上海绿地 [9] => 长春亚泰 [10] => 杭州绿城 [11] => 大连阿尔滨 [12] => 上海申鑫 [13] => 河南建业 [14] => 辽宁宏运 [15] => 哈尔滨毅腾 ) [3] => Array ( [0] => 20 [1] => 19 [2] => 19 [3] => 19 [4] => 19 [5] => 19 [6] => 19 [7] => 18 [8] => 20 [9] => 19 [10] => 19 [11] => 19 [12] => 19 [13] => 19 [14] => 19 [15] => 18 ) [4] => Array ( [0] => 45 [1] => 41 [2] => 34 [3] => 31 [4] => 30 [5] => 28 [6] => 27 [7] => 25 [8] => 23 [9] => 21 [10] => 21 [11] => 20 [12] => 19 [13] => 17 [14] => 16 [15] => 12 ))Array( [1] => Array ( [0] => 01 [1] => 02 [2] => 03 [3] => 04 [4] => 04 [5] => 04 [6] => 04 [7] => 08 [8] => 09 [9] => 09 [10] => 09 [11] => 09 [12] => 09 [13] => 09 [14] => 15 [15] => 15 ) [2] => Array ( [0] => 埃尔克森 [1] => 哈默德 [2] => 海森 [3] => 达维 [4] => 多利 [5] => 洛维 [6] => 拉蒙 [7] => 德扬 [8] => 巴塔拉 [9] => 布鲁诺 [10] => 里卡多 [11] => 武磊 [12] => 埃尼奥 [13] => 尤里 [14] => 莫雷诺 [15] => 雷内 ) [3] => Array ( [0] => 17 [1] => 16 [2] => 13 [3] => 9 [4] => 9 [5] => 9 [6] => 9 [7] => 8 [8] => 7 [9] => 7 [10] => 7 [11] => 7 [12] => 7 [13] => 7 [14] => 6 [15] => 6 ) [4] => Array ( [0] => 广州恒大 [1] => 广州富力 [2] => 上海东亚 [3] => 广州富力 [4] => 哈尔滨毅腾 [5] => 山东鲁能 [6] => 杭州绿城 [7] => 北京国安 [8] => 北京国安 [9] => 大连阿尔滨 [10] => 哈尔滨毅腾 [11] => 上海东亚 [12] => 长春亚泰 [13] => 贵州茅台 [14] => 上海绿地 [15] => 广州恒大 ))*/ 后面的自己处理吧
$url = 'http://sports.sohu.com/zhongchao.shtml';$s = file_get_contents($url);preg_match_all('/(?)\s Array( [2] =>
|
上一篇: 实例讲解jQuery EasyUI tree中state属性慎用
下一篇: Jedis的使用
网友评论
文明上网理性发言,请遵守 新闻评论服务协议
我要评论