Scraping Javascript Array
I had a problem with scraping a site http://www.weather.bm/radarMobile.asp, Fatherstorm gave me a great solution but it had some minor bugs in regards to start time and number of i
Solution 1:
Read the PHP manual on regular expressions. In this case it's as simple as:
$html = file_get_contents('http://www.weather.bm/radarMobile.asp');
preg_match('/radarFileNames = new Array\((.+?)\);/ims', $html, $m);
$files = explode(",", $m[1]);
// then output <img>s
The explode() is easier here than preg_split. But then requires a trim()
on each filename in the array, and a second trim($filename, "'")
to get rid of the enclosing quotes.
Post a Comment for "Scraping Javascript Array"