Last active
March 3, 2020 06:38
-
-
Save iggyvolz/7be402966ce757b8e4a4596e865eb54f to your computer and use it in GitHub Desktop.
This file contains hidden or 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 | |
$conts = file_get_contents("https://projects.fivethirtyeight.com/2020-primary-forecast/"); | |
$obj = []; | |
foreach(explode("\n", $conts) as $line) { | |
$line = trim($line); | |
if(preg_match("/^interactivePage\\.([a-z]+) = (.+);$/", $line, $matches)) { | |
[$_, $key, $value] = $matches; | |
if($value[0] === "'") $value = str_replace("'", '"', $value); | |
$obj[$key] = json_decode($value, true); | |
} | |
} | |
var_dump($obj); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment