Instant87 Posted October 31, 2008 Share Posted October 31, 2008 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 More sharing options...
GingerRobot Posted October 31, 2008 Share Posted October 31, 2008 What's not working? What happens? Do you get error messages? Have you tried echoing $data1 to make sure you're retrieving the webpage ok? Link to comment https://forums.phpfreaks.com/topic/130924-php-get-url-curl/#findComment-679639 Share on other sites More sharing options...
Instant87 Posted November 1, 2008 Author Share Posted November 1, 2008 I fixed all the error messages I'm getting and now I'm just getting a page that returns: Cash: Also I tried changing the echo to {$matches[1]} which doesn't work Link to comment https://forums.phpfreaks.com/topic/130924-php-get-url-curl/#findComment-680067 Share on other sites More sharing options...
GingerRobot Posted November 1, 2008 Share Posted November 1, 2008 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 More sharing options...
Instant87 Posted November 2, 2008 Author Share Posted November 2, 2008 Is there any useful tutorials on how to use the functions that you stated above? Link to comment https://forums.phpfreaks.com/topic/130924-php-get-url-curl/#findComment-680536 Share on other sites More sharing options...
GingerRobot Posted November 2, 2008 Share Posted November 2, 2008 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 More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.