Created
October 24, 2017 17:14
-
-
Save hutattedonmyarm/a9493abe508630b3f18e7255326e6e2d 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 | |
$html = file_get_contents('https://wiki.pnut.io/PCA'); | |
$doc = new DOMDocument(); | |
$doc->loadHTML($html); | |
$tables = $doc->getElementsByTagName('table'); | |
$pca = array(); | |
foreach ($tables as $table) { | |
if ($table->hasAttribute('class') && $table->getAttribute('class') == 'wikitable') { | |
foreach ($table->childNodes as $childNode) { | |
$entry = $childNode->getElementsByTagName('td'); | |
if ($entry->length > 0) { | |
$achievement["pca"] = $entry->item(0)->textContent; | |
$achievement["emoji"] = $entry->item(1)->textContent; | |
$achievement["post_count"] = $entry->item(2)->textContent; | |
$achievement["inventor"] = $entry->item(3)->textContent; | |
$pca[] = $achievement; | |
} | |
} | |
} | |
} | |
echo json_encode($pca); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment