Jump to content

Reading a variable from one site


9three

Recommended Posts

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.

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?

<?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.

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.