您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

抓取YAHOO股票报价的类_PHP教程

2025/3/19 10:57:26发布18次查看
复制代码 代码如下:
function getyahooquote($stocksymbol = ccr)
{
if (!$targeturl) $targeturl = http://finance.yahoo.com/q?s=$stocksymbol&d=t; //设定要抓取的url目标
$fd = fopen($targeturl, r);
$stopextract = 0;
$startextract = 0;
while (!feof($fd))
{
$buffer = fgets($fd, 4096);
//echo trim($buffer).\n;
if (strstr($buffer, rowspan=3))
{
//echo extract started at line #$linecount\n;
$startextract = 1;
}
if ($startextract && !$stopextract)
{
if (strstr($buffer, {
$startpos = strrpos($buffer, $buffer = substr($buffer, $startpos);
}
//$text = trim(strip_tags($buffer));
//echo trim($buffer).\n;
$buffer = str_replace(\n\r, , $buffer);
if (strstr($buffer, http://ichart.yahoo.com/v?s=$stocksymbol))
{
//echo ichart found!;
$stopextract = 1;
}
$capturedhtml .= $buffer;
}
if ($startextract && strstr($buffer,
))
{
$stopextract = 1;
//echo extract stopped at line #$linecount\n;
echo $capturedhtml;
break;
}
$linecount ;
}
fclose($fd);
}
//以下为抓取的一个例子
$symbols = array('ccr', 'iixl','sape','wbvn' );
$symbolcount = count($symbols);
for ($i=0; $i{
echo $symbols[$i]
;
getyahooquote($symbols[$i]);
}
?>
http://www.bkjia.com/phpjc/320117.htmlwww.bkjia.comtruehttp://www.bkjia.com/phpjc/320117.htmltecharticle复制代码 代码如下: ? function getyahooquote($stocksymbol = ccr) { if (!$targeturl) $targeturl = http://finance.yahoo.com/q?s=$stocksymbol //设定要抓取的url目标 $...
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product