1
此代码是工作了好几天,直到它停在最糟糕的时候工作。它只是从NOAA网站提取天气预报信息并将其显示在我的页面上。有人可以告诉我为什么这会突然失败吗?为什么preg_match_all突然停止工作?
$file = file_get_contents("http://forecast.weather.gov/showsigwx.php?warnzone=ARZ018&warncounty=ARC055");
preg_match_all('#<div id="content">([^`]*?)<\/div>#', $file, $matches);
$content = $matches[1];
echo "content = ".$content."</br>" ;
echo "matches = ".$matches."</br>" ;
print_r ($matches); echo "</br>";
echo "file </br>".$file."</br></br>" ;
现在我所得到的只是一个空的数组。
这是输出..
content = Array
matches = Array
Array ([0] => Array () [1] => Array ())
file = the full page as requested by file_get_contents
WOW。谢谢。我从来不会抓到那个。我对PHP非常陌生,并且正在努力学习。你推荐我用什么? – user1928523
[DOM文档:: loadHTML()](http://docs.php.net/manual/en/domdocument.loadhtml.php)工作得很好,并内置到PHP。 –
我真的很感激输入和我一直在试图让我的头解决这个问题,失败,过去一小时。我通常更喜欢学习我在做什么,但我真的需要快速恢复。我将如何实现DOM方法? – user1928523