欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  后端开发

采集网站 正则表达式和结果输出 问题

程序员文章站 2022-06-12 22:29:11
...
采集到输出错误,看看是正则语句问题吗



 function request_by_curl($remote_server, $post_string){    $ch = curl_init();    curl_setopt($ch, CURLOPT_URL, $remote_server);    curl_setopt($ch, CURLOPT_POSTFIELDS, 'mypost=' . $post_string);    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);    curl_setopt($ch, CURLOPT_USERAGENT, "Jimmy's CURL Example beta");    $data = curl_exec($ch);    curl_close($ch);    return $data;}$string = request_by_curl("http://www.bwlc.net/bulletin/keno.html",80);  $pat = '/\[\s\S]*?\(.*?)\[\s\S]*?\
(.*?)\[\s\S]*?\
(.*?)\[\s\S]*?\
(.*?)\[\s\S]*?\/i';preg_match_all($pat,$string,$outstr);foreach($outstr as $key => $value){ 	echo "第".$outstr[$key][1]."期,开奖结果为:".$outstr[$key][2]."飞盘:".$outstr[$key][3]."时间:".$outstr[$key][4]."\n";}  


回复讨论(解决方案)

你把匹配结果数组的格式理解错了

foreach($outstr[0] as $key => $value){     echo "第".$outstr[1][$key]."期,开奖结果为:".$outstr[2][$key]."飞盘:".$outstr[3][$key]."时间:".$outstr[4][$key]."\n";}
第712522期,开奖结果为:55,09,59,43,04,28,58,70,13,46,42,73,16,51,30,75,11,41,25,69飞盘:01时间:2015-08-20 23:55第712521期,开奖结果为:39,51,10,48,57,25,35,16,78,33,47,20,71,37,42,17,59,49,28,01飞盘:03时间:2015-08-20 23:50第712520期,开奖结果为:38,48,12,27,23,59,13,30,18,60,08,20,15,45,31,05,41,25,01,17飞盘:02时间:2015-08-20 23:45第712519期,开奖结果为:36,28,69,13,42,21,73,05,26,15,58,44,03,56,35,02,19,47,66,06飞盘:01时间:2015-08-20 23:40第712518期,开奖结果为:28,71,47,57,22,66,62,36,02,53,63,07,60,64,35,46,15,78,39,58飞盘:03时间:2015-08-20 23:35第712517期,开奖结果为:74,05,23,11,50,34,04,49,26,01,13,40,54,08,29,24,73,09,31,15飞盘:02时间:2015-08-20 23:30第712516期,开奖结果为:27,40,13,76,38,52,24,75,44,49,14,72,65,35,04,47,67,07,57,71飞盘:01时间:2015-08-20 23:25第712515期,开奖结果为:06,68,31,03,16,63,75,09,44,30,77,12,46,17,79,07,27,15,71,47飞盘:03时间:2015-08-20 23:20第712514期,开奖结果为:01,32,42,06,39,60,20,25,14,75,24,38,19,71,31,33,17,70,41,23飞盘:01时间:2015-08-20 23:15第712513期,开奖结果为:57,11,36,33,74,15,41,31,75,07,32,18,52,42,06,45,34,03,30,44飞盘:02时间:2015-08-20 23:10第712512期,开奖结果为:47,50,13,64,57,32,03,48,58,07,56,61,29,42,12,75,35,55,25,67飞盘:10时间:2015-08-20 23:05第712511期,开奖结果为:49,21,79,07,29,17,64,53,05,60,47,02,20,59,66,12,48,40,67,15飞盘:01时间:2015-08-20 23:00第712510期,开奖结果为:22,80,37,53,27,79,40,46,26,76,61,33,12,42,69,16,60,74,31,39飞盘:01时间:2015-08-20 22:55第712509期,开奖结果为:64,42,07,57,35,01,25,46,66,17,37,33,67,18,41,26,77,14,32,22飞盘:01时间:2015-08-20 22:50第712508期,开奖结果为:62,02,55,63,16,25,06,73,22,52,08,72,27,42,07,71,61,18,01,32飞盘:01时间:2015-08-20 22:45第712507期,开奖结果为:34,64,74,17,55,47,78,21,59,36,79,16,40,29,72,61,15,68,51,13飞盘:02时间:2015-08-20 22:40第712506期,开奖结果为:23,70,67,37,04,57,68,18,66,69,33,46,19,77,45,64,28,75,48,62飞盘:01时间:2015-08-20 22:35第712505期,开奖结果为:58,20,43,27,59,17,31,21,54,44,15,46,39,11,24,45,57,19,41,35飞盘:03时间:2015-08-20 22:30第712504期,开奖结果为:29,53,14,72,42,50,12,71,61,26,03,45,65,05,59,68,23,32,09,74飞盘:02时间:2015-08-20 22:25第712503期,开奖结果为:29,20,67,45,10,50,34,09,22,46,74,14,35,31,77,15,38,28,79,13飞盘:01时间:2015-08-20 22:20第712502期,开奖结果为:49,60,19,30,07,76,27,45,17,70,37,44,11,61,56,21,05,38,58,06飞盘:03时间:2015-08-20 22:15第712501期,开奖结果为:39,04,26,57,65,17,41,36,68,21,43,32,76,12,34,22,64,54,06,60飞盘:02时间:2015-08-20 23:55第712500期,开奖结果为:56,26,02,41,58,05,50,63,22,31,07,72,27,48,18,68,39,46,10,65飞盘:02时间:2015-08-20 22:05第712499期,开奖结果为:50,15,74,63,28,08,45,67,09,54,72,25,43,14,80,31,53,21,76,44飞盘:02时间:2015-08-20 22:00第712498期,开奖结果为:10,52,29,79,03,37,12,62,55,02,58,45,01,21,57,66,08,47,39,78飞盘:04时间:2015-08-20 21:55第712497期,开奖结果为:77,30,49,13,72,36,46,12,70,56,22,03,43,61,05,55,65,18,35,08飞盘:03时间:2015-08-20 21:50第712496期,开奖结果为:15,48,41,06,46,29,02,16,45,49,10,39,27,56,13,40,22,66,09,24飞盘:01时间:2015-08-20 21:45第712495期,开奖结果为:02,41,71,19,25,07,80,24,38,13,79,26,30,11,77,43,20,01,29,50飞盘:04时间:2015-08-20 21:40第712494期,开奖结果为:06,30,66,72,09,50,41,75,14,52,32,76,08,34,18,71,61,07,68,42飞盘:02时间:2015-08-20 21:35第712493期,开奖结果为:78,72,31,08,61,74,13,69,77,28,52,16,80,46,67,26,79,59,63,23飞盘:04时间:2015-08-20 21:30
采集网站 正则表达式和结果输出 问题

声明:本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn核实处理。

相关文章

相关视频


网友评论

文明上网理性发言,请遵守 新闻评论服务协议

我要评论
  • 采集网站 正则表达式和结果输出 问题
  • 专题推荐

    作者信息
    采集网站 正则表达式和结果输出 问题

    认证0级讲师

    推荐视频教程
  • 采集网站 正则表达式和结果输出 问题javascript初级视频教程
  • 采集网站 正则表达式和结果输出 问题jquery 基础视频教程
  • 视频教程分类