0

I wanna receive Foreign exchange rate from A reference site but each 30 minutes they're change how to get automatically and archive it in my data base for example : get it from a table and import to a specific div tag?

Erfan_
  • 11
  • Use file_get_contents and check this: http://stackoverflow.com/questions/8847663/ – Cyborg Nov 30 '13 at 09:12
  • I'd like receive all tables once every 30 minutes and import it to a container class for Show the same and save their informations to my database My site is Based on html ,sql and css [1]: http://www.sarafijalalii.com/ – Erfan_ Nov 30 '13 at 09:50

2 Answers2

0
  1. If you're on a Linux host, use crontab to setup a script that will run every 30 minutes. You can use Task Scheduler if you're on a Windows host.
  2. Read in the contents of the URL using file_get_contents.
  3. Parse said contents (will depend on the type of data - Do they have the data available in XML or JSON, or will you need to parse the HTML with a DOM Parser?).
  4. Save the relevant data to your database.
Wayne Whitty
  • 19,513
  • 7
  • 44
  • 66
0

Your question is reasonably vague, in that you don't specify exactly which site you want to get data out of.

Unless the site offers a programmatic API (which seems unlikely for forex) you are left with a number of options.

  • Use file_get_contents() in PHP to download the HTML of the page and use regular expressions to get the data you need
    • Note that this is pretty tricky, you have to write the regexes, and it depends on the site not loading the content through JavaScript after the page has loaded (so may not be as simple as suggested)
  • Use an external service to convert the page to data, for example http://import.io (I work there). You can pull this data straight in using PHP and put it in your database using a cron script or other scheduler.
Chris Alexander
  • 1,212
  • 14
  • 19