0

Here's my code:

<?php
    set_time_limit(0);
    $agent = 'User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.3) Gecko/2008100922 Ubuntu/8.04 (hardy) Firefox/3.0.3';
    $url = "XXXXXXXX";

    $ch = curl_init ($url);
    curl_setopt($ch, CURLOPT_USERAGENT, $agent);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
    $data = curl_exec ($ch);
    curl_close($ch);

    $regex = '/<tr>(.*?)<\/tr>/s';
    preg_match_all($regex,$data,$match);
    $tr = $match[0][0];
    var_dump($tr);

if(curl_errno($ch)){ // check for execution errors
    echo 'Scraper error: ' . curl_error($ch);
    exit;
}
?>

Here's what's outputted:

array (size=0)
  empty

Here's what's being scraped:

<table>
    <tr><td>Title</td><td>Message</td></tr>
    <tr><td>Title</td><td>Message</td></tr>
</table>

Any ideas for troubleshooting to make sure the page is being loaded correctly or anything obvious that I'm missing?

Here's the error I am receiving:

 Warning: curl_errno(): 2 is not a valid cURL handle resource in 

I suppose it looks like it's due to a lack of SSL. Thanks for the assistance everybody.

4

0 回答 0