Created
February 18, 2020 17:31
-
-
Save Muqsit/fc75b26703ea7bffbed9353b2a750255 to your computer and use it in GitHub Desktop.
A script that parses server ip:port from minecraftpocket-servers.com
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 | |
| $pages = (int) $argv[1]; | |
| $output = $argv[2]; | |
| if(file_exists($output)){ | |
| echo "File " . $output . " already exists." . PHP_EOL; | |
| return; | |
| } | |
| $url = "https://minecraftpocket-servers.com/servers/list/"; | |
| $fp = fopen($output, "w"); | |
| if($fp === false){ | |
| echo "Invalid file name \"" . $output . "\" given." . PHP_EOL; | |
| return; | |
| } | |
| $found = 0; | |
| for($i = 1; $i <= $pages; ++$i){ | |
| echo "Fetching HTML contents of page #" . $i . PHP_EOL; | |
| $contents = file_get_contents($url . $i . "/"); | |
| echo "Parsing server addresses of page #" . $i . PHP_EOL; | |
| $read = 0; | |
| $search = "data-clipboard-text="; | |
| $search_len = strlen($search); | |
| while(($read = strpos($contents, $search, $read)) !== false){ | |
| $read += $search_len + 1; | |
| $read_till = strpos($contents, "\"", $read); | |
| $server = substr($contents, $read, $read_till - $read); | |
| fwrite($fp, $server . PHP_EOL); | |
| echo ++$found . ". " . $server . PHP_EOL; | |
| } | |
| } | |
| fclose($fp); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment