note 62194 modified in ref.curl by danbrown
| From: | danbrown@php.net | Date: | Sun, 17 May 2009 19:31:38 +0000 |
| Subject: | note 62194 modified in ref.curl by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-155230@lists.php.net to get a copy of this message | ||
I had the following experience when harvesting urls with a get variable from a page using cUrl. HTML
pages will output ampersands as & when the page is read by the curl function.
If you code a script to find all hyperlinks, it will use & instead of &, especially using
a regular expression search.
It is hard to detect because when you output the url to the browser it renders the html. To fix, add
a line to replace the & with &.
<?php
function processURL($url){
$url=str_replace('&','&',$url);
$ch=curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
$xml = curl_exec ($ch);
curl_close ($ch);
echo $xml;
}
?>
--was--
I had the following experience when harvesting urls with a get variable from a page using cUrl. HTML
pages will output ampersands as & when the page is read by the curl function.
If you code a script to find all hyperlinks, it will use & instead of &, especially using
a regular expression search.
It is hard to detect because when you output the url to the browser it renders the html. To fix, add
a line to replace the & with &.
function processURL($url){
$url=str_replace('&','&',$url);
$ch=curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
$xml = curl_exec ($ch);
curl_close ($ch);
echo $xml;
}
}
http://php.net/manual/en/ref.curl.php