Jump to content

problem getting content of a site with CURL


darkdmr

Recommended Posts

I want to get soccer fixtures from a famous bookmaker, so I save them in my database and make my own statistics.

 

Problem is that to get the content of the page, With the normal browser I should go to first page, which sets session ID variable, and only then I can go to the page I want.

 

How can I make it that way with PHP? 2 Curl requests ? And how my script will store the session ID of the first curl execution, to provide them to the second ?

I tried that way :

$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, $siteMainPage);

curl_setopt ($ch, CURLOPT_COOKIEJAR, 'cookie.txt');

curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);

$store = curl_exec ($ch);

curl_setopt($ch, CURLOPT_URL, $siteInnerPage);

$content = curl_exec ($ch);

curl_close ($ch);

echo $content;

 

 

and it even doesn't print the first page's content ?

The curl_error gives me this :

 

SSL certificate problem, verify that the CA cert is OK. Details: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed

 

Also, the site is with https, I hope that is not problem ?

 

 

I never handled requests through https, but I dont think there should be a problem. Try this:

 

<?php

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $siteMainPage);
curl_setopt ($ch, CURLOPT_COOKIEJAR, 'cookie.txt');
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE); 
curl_exec ($ch);
unset($ch)

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $siteInnerPage);
curl_setopt ($ch, CURLOPT_COOKIEJAR, 'cookie.txt');
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE); 
$store = curl_exec ($ch);
unset($ch);
echo $store;

?>

 

 

Orio.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.