Created
April 21, 2016 04:12
-
-
Save pviojo/6913de3eddd393a779866874f3a19d00 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$content = file_get_contents("http://www.meteochile.cl/js/condicionactualmetar.js?" . time()); | |
$lines = explode("\n", $content); | |
$lastUpdated = str_replace("var CondicionActualMetar_actualizado = '", "", str_replace(".';", "", $lines[count($lines)-4])); | |
$data = []; | |
$data['lastUpdated'] = $lastUpdated; | |
$data['ciudades'] = []; | |
$lines = array_slice($lines, 3, count($lines)-8); | |
foreach($lines as $l){ | |
list($a,$b) = explode(" = '", $l); | |
$data['ciudades'][str_replace("CondicionActualMetar['", "", str_replace("']", "", $a))] = explode("|", str_replace("';", "", $b)); | |
} | |
var_dump($data); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment