infohassan

Untitled

Sep 11th, 2017
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.89 KB | None | 0 0
  1. <?php
  2. error_reporting(E_ERROR);
  3. $urls[] = "http://myurl.com/page.html";
  4.  
  5. function curlLoad($url) {
  6.         $ch = curl_init();
  7.         curl_setopt($ch, CURLOPT_URL,$url);
  8.         curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  9.         curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
  10.         curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
  11.         curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 1);
  12.         $source = curl_exec($ch);
  13.         return $source;
  14. }
  15.  
  16. foreach ($urls as $url) {
  17.         $source = curlLoad($url);
  18. @$doc = new DOMDocument();
  19. @$doc->loadHTML($source);  
  20.  
  21. $xpath = new DomXPath($doc);
  22. $nodeList = $xpath->query("//div[@class='pageContent']");
  23. $node = $doc->saveHTML($nodeList->item(0));
  24.  
  25. //foreach($nodeList as $node) {
  26. //    echo $node->nodeValue;
  27. //}
  28.  
  29. // To check the result:
  30. echo "<p>". preg_replace('/<script\b[^>]*>(.*?)<\/script>/is', "", $node); . "</p>";
  31.  
  32.  
  33. }
  34.  
  35. ?>
Add Comment
Please, Sign In to add comment