0

yahoo から引用符を取得する単純な (つまり単純な) 正規表現コードがあります。

私が欲しいのは、URLをユーザーが入力したものに置き換える入力ボックスを持つことができるようにすることです. したがって、ユーザーが fb の株価を見たい場合、ユーザーはそれをフォーム フィールドに入力して [Go] を押すと、取得する URL がユーザー入力に変わります。

URL を使用するユーザーは 3 人だけです。

これが私のコードです:

<?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 に答える