Code: Select all
function fetch($url, $post=false, $referer="")
{
$useragent="Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1.1.4322)";
$ch = curl_init();
if($post)
{
curl_setopt($ch, CURLOPT_POST,1);
curl_setopt ($ch, CURLOPT_POSTFIELDS, "$post");
}
//use proxy?
if($this->useProxies && $this->CURRENT_PROXY)
{
curl_setopt ($ch, CURLOPT_PROXY, "http://".$this->CURRENT_PROXY);
}
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_USERAGENT, $useragent);
curl_setopt ($ch, CURLOPT_COOKIEJAR, "c:\cookie.txt");
curl_setopt ($ch, CURLOPT_HEADER, 0);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt ($ch, CURLOPT_TIMEOUT, 60);
if(!empty($referer))
curl_setopt($ch, CURLOPT_REFERER, $referer);
$content = curl_exec($ch);
curl_close ($ch);
return $content;
}
$input_file = fetch("https://secure.telewest.com.au/myacen/", true, "");
echo $input_file;That's not the real https page I want to grab, but it's an example. I tried with file_get_contents since that's how I usually do my grabbing and reg expressions after, but it gave me errors on SSL or something for file_get_contents.
I need to grab all the source code of a webpage on https:// into ONE php string variable, such as $input_file, so I can then do my preg_match and validate what needs to be validated.
Any help is very much appreciated, I'm trying to do this as fast as possible for a friend and ran into that problem, right now the above script outputs nothing and I want it to output the real page (exampe setting up a web proxy is what this script may be used for, but a very simple one and easy to read, nothing like the open source ones out there that are over 20 kb in size and three dozen files). Help me please~!
Thanks in advance!!!!!