9three Posted February 16, 2009 Share Posted February 16, 2009 Hey, Is it possible to grab a variable/integer from one site and based on that site's variable/integer to update on my site? Is this where cron jobs come in? Link to comment https://forums.phpfreaks.com/topic/145485-reading-a-variable-from-one-site/ Share on other sites More sharing options...
allworknoplay Posted February 16, 2009 Share Posted February 16, 2009 You can grab whatever you want from another site if you know what you are looking for. But you can't grab variables since sites don't output variables they output the VALUE... Link to comment https://forums.phpfreaks.com/topic/145485-reading-a-variable-from-one-site/#findComment-763775 Share on other sites More sharing options...
9three Posted February 17, 2009 Author Share Posted February 17, 2009 ok. To pull VALUES from a site which function is available? crons? Not sure really. Link to comment https://forums.phpfreaks.com/topic/145485-reading-a-variable-from-one-site/#findComment-763783 Share on other sites More sharing options...
trq Posted February 17, 2009 Share Posted February 17, 2009 file_get_contents Link to comment https://forums.phpfreaks.com/topic/145485-reading-a-variable-from-one-site/#findComment-763794 Share on other sites More sharing options...
premiso Posted February 17, 2009 Share Posted February 17, 2009 curl is another alternative. Link to comment https://forums.phpfreaks.com/topic/145485-reading-a-variable-from-one-site/#findComment-763827 Share on other sites More sharing options...
alphanumetrix Posted February 17, 2009 Share Posted February 17, 2009 i'm pretty sure cron jobs is basically where you put ads on your site and earn credit for it. has nothing to do with php. Link to comment https://forums.phpfreaks.com/topic/145485-reading-a-variable-from-one-site/#findComment-763960 Share on other sites More sharing options...
premiso Posted February 17, 2009 Share Posted February 17, 2009 i'm pretty sure cron jobs is basically where you put ads on your site and earn credit for it. has nothing to do with php. Umm no. A cron job is a task that runs at a certain time(s) automatically which you specify and is specific to unix. It really does not have to do with PHP other than you can setup a cron job to run a php script on your server if you have a linux server. The equivalent to this in Windows is Scheduled Tasks. Do some googling if you want to learn more on Cron jobs. Link to comment https://forums.phpfreaks.com/topic/145485-reading-a-variable-from-one-site/#findComment-763964 Share on other sites More sharing options...
9three Posted February 17, 2009 Author Share Posted February 17, 2009 Hey, thanks for the replies. I decided to go with file_get_contents. a cURL might be an overkill for this. <?php $gold = file_get_contents('http://www.sitek.com/'); preg_match('~<span id = "XAU_B">(.+?)</span>~is', $gold, $goldMatch); foreach ($goldMatch as $gMatched) echo $gMatched; ?> The problem is that the actual information between the span is that they are images and they dont show up when I load my script. The image dynamically changes on it's own. Is it possible that PHP can't handle images only strings? Link to comment https://forums.phpfreaks.com/topic/145485-reading-a-variable-from-one-site/#findComment-763993 Share on other sites More sharing options...
trq Posted February 17, 2009 Share Posted February 17, 2009 file_get_contents retrieves a string. What exactly are you trying to do and can we see some example data? Link to comment https://forums.phpfreaks.com/topic/145485-reading-a-variable-from-one-site/#findComment-764034 Share on other sites More sharing options...
premiso Posted February 17, 2009 Share Posted February 17, 2009 <?php $gold = file_get_contents('http://www.sitek.com/'); ?> sitek.com does not have <span anywhere inside of it's source. Thus your preg_match code would never execute right. If sitek.com is the site you want to parse, what are you trying to get out of that site? If not please post the site you want to parse so we can further help you. Link to comment https://forums.phpfreaks.com/topic/145485-reading-a-variable-from-one-site/#findComment-764232 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.