我正在努力抓www.weather.bm。我想要所有10个雷达图像,但我只能得到一个(图像定期更新)并且它不是绝对的图像网址。我希望我可以将图像用作链接的图像幻灯片,但不知道如何。另外,如何删除images/Radarlegend.png
?我只需要雷达图像。
这是我的代码:
include('simple_html_dom.php');
$html = file_get_html('http://www.weather.bm/radarMobile.asp');
foreach($html->find('img') as $element)
echo $element->src . '<br>'
我的输出是:
<div id="main">
images/Radar/CurrentRadarAnimation_100km_sri/100km_sri-radar-2011-01-04-1556.jpg<br>images/Radarlegend.png<br></div>
</div>
答案 0 :(得分:0)
$localOffset = "+2 Hours"; //change this to your local offset from the image times you need. for me (CST) it's 2 hours.....
$start= strtotime("-90 Minutes " . $localOffset); // go back 90 minutes (The limit of the available images)
$start=($start-($start % (600))+(60*6)); //go to the next earlier 6 minute mark (all images appear to be at the 6 minute mark))appear to be at the 6 minute mark))
for($x=1;$x<=9;$x++){
$DateTime = date("Y-m-d-Hi", $start); // set the image time we want.
$fName = ("http://www.weather.bm/images/Radar/CurrentRadarAnimation_100km_sri/100km_sri-radar-$DateTime.jpg"); // set the filename
echo" $min <img src='$fName' alt='$fName'/><br/>"; // echo (or add to a stack or variable...) your image node
$start+=(600);//add 10 minutes
}
答案 1 :(得分:0)
JavaScript中有所有十个图像的列表(格式更改为我的):
radarFileNames = new Array(
'images/Radar/CurrentRadarAnimation_100km_sri/100km_sri-radar-2011-01-04-1446.jpg',
'images/Radar/CurrentRadarAnimation_100km_sri/100km_sri-radar-2011-01-04-1456.jpg',
'images/Radar/CurrentRadarAnimation_100km_sri/100km_sri-radar-2011-01-04-1506.jpg',
'images/Radar/CurrentRadarAnimation_100km_sri/100km_sri-radar-2011-01-04-1516.jpg',
'images/Radar/CurrentRadarAnimation_100km_sri/100km_sri-radar-2011-01-04-1526.jpg',
'images/Radar/CurrentRadarAnimation_100km_sri/100km_sri-radar-2011-01-04-1536.jpg',
'images/Radar/CurrentRadarAnimation_100km_sri/100km_sri-radar-2011-01-04-1546.jpg',
'images/Radar/CurrentRadarAnimation_100km_sri/100km_sri-radar-2011-01-04-1556.jpg',
'images/Radar/CurrentRadarAnimation_100km_sri/100km_sri-radar-2011-01-04-1606.jpg');
对包含radarFileNames = new Array
的行进行简单搜索将返回此行。然后,您可以使用两个preg_split()
s提取网址:首先在\(|\)
上,然后在', '
上拆分第二个标记。最后,将http://www.weather.bm/
添加到网址。