Skip to content

Instantly share code, notes, and snippets.

@pviojo
Created April 21, 2016 04:12
Show Gist options
  • Save pviojo/6913de3eddd393a779866874f3a19d00 to your computer and use it in GitHub Desktop.
Save pviojo/6913de3eddd393a779866874f3a19d00 to your computer and use it in GitHub Desktop.
<?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