2012-05-23 39 views
0

將URL添加到正則表達式我有一個簡單的(我的意思是簡單的)正則表達式代碼,從雅虎拉引號。從表單

我想要的是能夠有一個輸入框,用任何用戶輸入替換url。因此,如果用戶想要查看fb的股票報價,用戶將在表單字段中輸入它並點擊,然後要獲取的網址將更改爲用戶輸入。

只有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]; 



?> 
+1

更換網址,可以請你的問題更清晰?你希望用戶能夠替換哪個URL?怎麼樣? – Ansari

回答

0

內這個

file_get_contents('http://finance.yahoo.com/q?s=CHANGEGOESHERE&ql=1');