DomDocumentParser.php 689 B

12345678910111213141516171819202122232425262728293031323334
  1. <?php
  2. class DomDocumentParser {
  3. private $doc;
  4. public function __construct($url) {
  5. $options = array(
  6. 'http'=>array('method'=>"GET", 'header'=>"User-Agent: doodleBot/0.1\n")
  7. );
  8. $context = stream_context_create($options);
  9. $this->doc = new DomDocument();
  10. @$this->doc->loadHTML(file_get_contents($url, false, $context));
  11. }
  12. public function getlinks() {
  13. return $this->doc->getElementsByTagName("a");
  14. }
  15. public function getTitleTags() {
  16. return $this->doc->getElementsByTagName("title");
  17. }
  18. public function getMetaTags() {
  19. return $this->doc->getElementsByTagName("meta");
  20. }
  21. public function getImages() {
  22. return $this->doc->getElementsByTagName("img");
  23. }
  24. }
  25. ?>