note 92864 modified in function.htmlspecialchars by danbrown

From: Date: Wed, 12 Aug 2009 15:47:59 +0000
Subject: note 92864 modified in function.htmlspecialchars by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-159370@lists.php.net to get a copy of this message
Need to dump the source of page retrieved via <a href="http://us3.php.net/curl">CURL</a>? I found it's easily done with htmlspecialchars() eg; <?php function get_page($url) { $curl = curl_init(); curl_setopt($curl, CURLOPT_URL, $url); curl_setopt($curl, CURLOPT_USERAGENT, 'some bot'); curl_setopt($curl, CURLOPT_HTTPHEADER, $header); curl_setopt($curl, CURLOPT_REFERER, '-'); curl_setopt($curl, CURLOPT_ENCODING, 'gzip,deflate'); curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1); ... curl_setopt($curl, CURLOPT_HEADER, 1); curl_setopt($curl, CURLOPT_NOBODY, 0); curl_setopt($curl, CURLOPT_TIMEOUT, 10); $html = curl_exec($curl); curl_close($curl); return $html; } $text = get_page($url); $new = htmlspecialchars($text, ENT_QUOTES); // here is the magic :) echo '<pre>' .$new. '</pre>'; ?> HTH --was-- Need to dump the source of page retrieved via <a href="http://us3.php.net/curl">CURL</a>? I found it's easily done with htmlspecialchars() eg; <?php function get_page($url) { $curl = curl_init(); curl_setopt($curl, CURLOPT_URL, $url); curl_setopt($curl, CURLOPT_USERAGENT, 'some bot'); curl_setopt($curl, CURLOPT_HTTPHEADER, $header); curl_setopt($curl, CURLOPT_REFERER, '-'); curl_setopt($curl, CURLOPT_ENCODING, 'gzip,deflate'); curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1); ... curl_setopt($curl, CURLOPT_HEADER, 1); curl_setopt($curl, CURLOPT_NOBODY, 0); curl_setopt($curl, CURLOPT_TIMEOUT, 10); $html = curl_exec($curl); curl_close($curl); return $html; } $text = disguise_curl($url); $new = htmlspecialchars($text, ENT_QUOTES); // here is the magic :) echo '<pre>' .$new. '</pre>'; ?> HTH http://php.net/manual/en/function.htmlspecialchars.php

« previous php.notes (#159370) next »