doupu1957 2012-05-23 00:46
浏览 44
已采纳

从表单添加URL到regex

I have a simple (and I mean simple) regex code that pulls quotes from yahoo.

What I want is to be able to have an input box that replaces the url with whatever the user inputs. So if user wants to see stock quote of fb the user will enter it in the form field and hit go and then the URL to fetch will change to user input.

There are only going to be 3 users using the url.

Here is my code:

<?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条回答 默认 最新

  • doupang5433 2012-05-23 13:55
    关注

    Replace url within this

    file_get_contents('http://finance.yahoo.com/q?s=CHANGEGOESHERE&ql=1');
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度