Forum Moderators: coopster

Message Too Old, No Replies

PHP and cURL

not working! help!

         

beaudeal

7:05 am on Jun 4, 2007 (gmt 0)

10+ Year Member



hi,

i've been using php and cURL to pull data from a site, and things worked just fine. however, when i used the same script to access a different site, not data is being returned. however, i can go to the url of the site being used and there is clearly html there which should theoretically be scraped. any idea why it is not being gathered and how can i fix this?

thanks a million!

eelixduppy

1:17 pm on Jun 4, 2007 (gmt 0)



No clue why it isn't working; are you getting any error messages? Also, if you want to grab the html, you can use file_get_contents [php.net] with allow_url_fopen on [php.net], and it should be a little easier :)

phparion

1:57 pm on Jun 4, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



every site has different HTML structure and you're probably using the same regex to fetch the results. try to tweak your regex and some checkpoints to make sure you are going in the right direction during the cURL session.

beaudeal

2:07 pm on Jun 4, 2007 (gmt 0)

10+ Year Member



hi everyone,

thanks for the feedback. i'm not getting any error messages which is the strange part, just empty results. i'm actually not too sure about the regex stuff, so i'll post my code (this is just an example of a page thats not working) here and maybe you can give me some suggestions. thanks again!

$ch = curl_init();
$timeout = 0;
curl_setopt ($ch, CURLOPT_URL, "http://www.facebook.com/ajax/networks_ajax.php?city=14330");
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
$file_contents = curl_exec($ch);
curl_close($ch);
echo $file_contents;

oh also, i don't think my server is configured to use file() :-/