Jump to content

PHP Get URL, Curl


Instant87

Recommended Posts

I'm building a script to take certain parts of a existing web page and put it into mine, so far I got this, however it's not working. Can anyone tell me what I'm doing wrong? ( It's soposed to extract the data that the site states after "<b>Cash:</b>")

 

<?php

$ch = curl_init() or die(curl_error());

curl_setopt($ch, CURLOPT_URL,"http://goallineblitz.com/game/team.pl?team_id=4504");

curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

$data1=curl_exec($ch) or die(curl_error());

preg_match('~<b>Cash</b>:(.+?)~', $data1, $matches);

echo "Cash: {$matches[0]}";

echo curl_error($ch);

curl_close($ch);

?>

Link to comment
https://forums.phpfreaks.com/topic/130924-php-get-url-curl/
Share on other sites

Having taken a look at the website in question; it's not as simple as that. You'll need to make two requests - the first to log in, the second to the page containing the data. You'll need to specify more curl options, including post fields and a cookie jar.

Link to comment
https://forums.phpfreaks.com/topic/130924-php-get-url-curl/#findComment-680069
Share on other sites

I keep meaning to write one, but i've not had time as yet. Other than that, all i can suggest is that you google. If you look for examples of retrieving data from facebook, myspace etc (there are a fair number of these) it might help you get the general gist.

Link to comment
https://forums.phpfreaks.com/topic/130924-php-get-url-curl/#findComment-680552
Share on other sites

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.