PHP cURL Include

/* Include Entire page with styles */ <?php $ch = curl_init(""); curl_setopt($ch, CURLOPT_HEADER, 0); curl_exec($ch); curl_close($ch); ?> /*Targeting DOM Elements*/ <?php $url = ""; $curl = curl_init($url); curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE); $output = curl_exec($curl); curl_close($curl); $DOM = new DOMDocument; $DOM->loadHTML($output); ?> <h1> <?php $items = $DOM->getElementsByTagName('h1'); //display all H1 text for ($i = 0; $i < $items->length; $i++) echo $items->item($i)->nodeValue . "<br/>"; ?> </h1> <div style="font-family: Lato;"> <?php $items = $DOM->getElementsByTagName('p'); //display all p text for ($i = 0; $i < $items->length; $i++) echo $items->item($i)->nodeValue . "<br/>"; ?> </div>
Basic PHP cURL include

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.