Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- error_reporting(E_ERROR);
- $urls[] = "http://myurl.com/page.html";
- function curlLoad($url) {
- $ch = curl_init();
- curl_setopt($ch, CURLOPT_URL,$url);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
- curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
- curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
- curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 1);
- $source = curl_exec($ch);
- return $source;
- }
- foreach ($urls as $url) {
- $source = curlLoad($url);
- @$doc = new DOMDocument();
- @$doc->loadHTML($source);
- $xpath = new DomXPath($doc);
- $nodeList = $xpath->query("//div[@class='pageContent']");
- $node = $doc->saveHTML($nodeList->item(0));
- //foreach($nodeList as $node) {
- // echo $node->nodeValue;
- //}
- // To check the result:
- echo "<p>". preg_replace('/<script\b[^>]*>(.*?)<\/script>/is', "", $node); . "</p>";
- }
- ?>
Add Comment
Please, Sign In to add comment