Last active
May 8, 2018 10:36
-
-
Save astf-robot/2b332daa479d714a192a to your computer and use it in GitHub Desktop.
Synonyms
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 | |
if ($argc < 2) { | |
echo "Usage ${argv[0]} WORD\n"; | |
exit(1); | |
} | |
$html = file_get_contents('http://www.thesaurus.com/browse/' . $argv[1]); | |
$dom = new DOMDocument(); | |
@$dom->loadHTML($html); | |
$xpath = new DOMXPath($dom); | |
$synonyms = $xpath->query('//a[@data-category]/span[@class="text"]'); | |
foreach ($synonyms as $synonym) { | |
echo $synonym->textContent . "\n"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment