我只想从HTML中获取表格详细信息,例如URL为
$url="https://www.centralbank.org.bz/rates-statistics/exchange-rates";
由此,我需要在此currency rate
中获取url
表,并删除所有dirty data
。
请帮帮我, 非常感谢
答案 0 :(得分:0)
试试这段代码::
$url = 'https://www.centralbank.org.bz/rates-statistics/exchange-rates'; $content = file_get_contents($url); $first_step = explode( '<table id="currencyTable">' , $content ); $second_step = explode("</table>" , $first_step[1] ); echo $second_step[0];
答案 1 :(得分:-1)
您应该使用Simple HTML DOM,
示例可能对您有所帮助:
<?php
include('simple_html_dom.php');
$url = 'https://www.phpbb.com/community/viewtopic.php?f=46&t=543171';
$html = file_get_html($url);
$links = array();
foreach($html->find('a[class="postlink"]') as $a) {
$links[] = $a->href;
}
print_r($links);
?>