我在抓取一個網站http://www.weather.bm/radarMobile.asp,Fatherstorm gave me a great solution時遇到了問題,但它在開始時間和圖像數量方面有一些小錯誤,有時會給出9或10,但代碼設置爲10。抓取javascript數組
另外一個人(marcog)給我this answer:
「,通過含radarFileNames =新的陣列將返回該行的行一個簡單的搜索然後你就可以提取網址有兩個
preg_split()
s:首先在\(|\)
上,然後將第二個標記拆分爲', '
。最後,將前綴http://www.weather.bm/
添加到URL中。「
我希望如果有人能告訴我他正在談論的代碼。我喜歡學習這種東西,但我沒有人教我。我希望你們能幫助
JavaScript數組:
radarFileNames = new Arra(
'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'
也將有可能輸出UL LI /李/ UL裏面的IMG它有它自己的類(UL類鋰類)
林也用簡單的HTML DOM解析器,但使用fatherstorm代碼 http://j2sdesign.com/rgw/article/20101222/NEWS01/712229951/0/example/r1.php
樣品我不能只加載的圖像是outputed這裏的圖片10
我從fatherstorm
?php
$localOffset = "+2 Hours"; //change this to your local offset from the image times you need. for me it's 1 hours.....
$start = strtotime("-100 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))
for ($x = 1; $x <= 10; $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" <center>$DateTime</center> <img class='radarImg' src='$fName' alt='$fName' title='$fName'/><br/."; // echo (or add to a stack or variable...) your image node
$start+= (600); //add 10 minutes
}
?
馬里奧代碼你的意思 這樣的:
<?php
$localOffset = "+2 Hours"; //change this to your local offset from the image times you need. for me it's 1 hours.....
$start = strtotime("-100 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))
for ($x = 1; $x <= 10; $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" <center>$DateTime</center> <img class='radarImg' src='$fName' alt='$fName' title='$fName'/><br/."; // echo (or add to a stack or variable...) your image node
$start+= (600); //add 10 minutes
$html = file_get_contents('http://www.weather.bm/radarMobile.asp'); preg_match('/radarFileNames = new Array\((.+?)\);/ims', $html, $m); $files = explode(",", $m[1]);
}
?>
我在這裏沒有真正看到問題。你爲什麼不要求marco澄清? –
-1,這是一個gimme teh codez post。 – goat