Home > Backend Development > PHP Tutorial > 财经数据抓取,想从网页抓取一段数据,请大神望里面的代码

财经数据抓取,想从网页抓取一段数据,请大神望里面的代码

WBOY
Release: 2016-06-13 12:07:31
Original
916 people have browsed it

财经数据抓取,想从网页抓取一段数据,请大神看里面的代码
$url = "http://www.gold678.com/indexs/business_calender.asp?date=2014-11-7"; 
$contents = file_get_contents($url); 

$str=preg_replace("/

(.*)/iU","$2",$contents);
echo $str; 

想得到这个表格里面的数据,但是这样匹配的话页面打开是都是超时的,不成功的,望大神指点
------解决思路----------------------
<br />header('content-type:text/html;charset=utf-8');<br />$url = "http://www.gold678.com/indexs/business_calender.asp?date=2014-11-7"; <br />$contents = iconv('gbk','utf-8',file_get_contents($url));<br />$str = array(); <br />$int1=preg_match("/<table width=\"770\".*?>(.*?)<\/table>/is",$contents,$str);<br />echo $str[0];<br />
Copy after login

仅作参考,没有检测是否有返回等情况
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template