2017-02-23 54 views
0

我想从外部URL获取官方日期和时间,并且我的PHP脚本不会返回我想要的值。你会那么好心帮我吗?从外部URL获取官方日期和时间

<?php 
// example of how to use basic selector to retrieve HTML contents 
require_once('simplehtmldom/simple_html_dom.php'); 

// get DOM from URL or file 
$html = file_get_html('http://www.cenam.mx/hora_oficial/'); 

// get and show the Mexico Center's Time 
$hcentro = $html->find('div[id=hcentro]', 0)->innertext; 
echo 'hcentro: '. $hcentro; 

// get and show the Mexico Center's Date 
$fcentro = $html->find('div[id=fcentro]', 0)->innertext; 
echo 'fcentro: '. $fcentro; 
?> 

结果我得到的仅仅是: hcentro:fcentro:

没有。为什么?我究竟做错了什么?

请帮我家伙

回答

0

hcentrodiv是空的:

Tiempo del Centro</strong> 
<div style="FONT-SIZE: 15pt;font-weight: bold; FONT-FAMILY: Times New Roman; " id="hcentro"> 
</div> 

同为其他div

原因是值是通过JavaScript创建的。您可能想深入了解JavaScript代码。

你为什么不使用REST service甚至a local public file

+0

感谢的LAUR伊万时,奇怪的是,使用VB6,我能得到的时间和与htmlDom对象外部URL的日期。 –