我想写一个页面抓取脚本来获取网站的货币。我需要一些帮助来编写正则表达式。页面抓取的正则表达式
这是我到目前为止。
<?php
function converter(){
// Create DOM from URL or file
$html = file_get_contents("http://www.bloomberg.com/personal- finance/calculators/currency-converter/");
// Find currencies. (using h1 to test)
preg_match('/<h1>(.*)<\/h1>/i', $html, $title);
$title_out = $title[1];
echo $title_out;
}
$foo = converter();
echo $foo;
?>
这里是货币保留在彭博网站上的地方。
网站:http://www.bloomberg.com/personal-finance/calculators/currency-converter/
//<![CDATA[
var test_obj = new Object();
var price = new Object();
price['ADP:CUR'] = 125.376;
什么会表达看起来希望得到这样的速度? 任何帮助将是伟大的!
不要使用正则表达式解析HTML代码;) – m0skit0 2012-02-20 17:48:11
在他使用的情况下,这是可以接受的。 – 2012-02-20 17:49:20
[How to parse HTML with PHP?](http://stackoverflow.com/questions/3650125/how-to-parse-html-with-php) – Gordon 2012-02-20 17:56:26