0

我有一个简单的(我的意思是简单的)正则表达式代码,它从雅虎中提取引号。

我想要的是能够有一个输入框,用用户输入的任何内容替换 url。因此,如果用户想查看 fb 的股票报价,用户将在表单字段中输入它并点击 go,然后要获取的 URL 将更改为用户输入。

只有 3 个用户使用该 url。

这是我的代码:

<?php
$content = file_get_contents('http://finance.yahoo.com/q?s=fb&ql=1');
$fb = file_get_contents('http://www.cbssports.com/mlb/teams/page/BOS/boston-red-sox');
$wod = file_get_contents('http://www.wordthink.com');
$ath = file_get_contents('http://finance.yahoo.com/q?s=ATHN');


preg_match('/<span id="yfs_l84_fb">(.*?)<\/span> <\/span>/i', $content, $match);
$price = $match[1];

preg_match('/<span id="yfs_l84_athn">(.*?)<\/span> <\/span>/i', $ath, $match);
$athp = $match[1];

preg_match('#<span id="yfs_l86_fb">(.*)</span></span></p></div>#', $content, $match);
$after = $match[1];

preg_match('/<table class="data" width="100%" >(.*?)<\/b><\/td><\/tr><\/table>/i', $fb,           $match);
$fbs = $match[1];

preg_match('/<b>(.*?)<\/b>/', $wod, $match);
$wod1 = $match[1];
preg_match('/<i>(.*?)<\/p>/', $wod, $match);
$wod2 = $match[1];



?>
4

1 回答 1

0

在此替换 url

file_get_contents('http://finance.yahoo.com/q?s=CHANGEGOESHERE&ql=1');
于 2012-05-23T13:55:27.063 回答