Last active
November 11, 2020 21:26
-
-
Save ahmedash95/e13b898426efedd7e50f623c44fb8b34 to your computer and use it in GitHub Desktop.
Codeforces problems scrapper
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 | |
$data = file_get_contents('https://codeforces.com/api/problemset.problems?tags=greedy'); | |
$data = json_decode($data, true)['result']['problems']; | |
$out = collect($data) | |
->filter(function($row){ | |
return isset($row['rating']) && $row['rating'] >= 500; | |
}) | |
->sortBy('rating') | |
->map(function($row){ | |
return [ | |
'contest' => $row['contestId'].$row['index'], | |
'name' => $row['name'], | |
'rating' => $row['rating'], | |
'link' => "https://codeforces.com/contest/{$row['contestId']}/problem/{$row['index']}", | |
'tags' => implode(', ', $row['tags']) | |
]; | |
}) | |
->values()->toJson() | |
; | |
file_put_contents('/home/greedy.json', $out); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment