Question

I'm making a clan website that I'd like to dynamically update from runescape's website to keep our clan data up to date. I'm planning on making a PHP script which I can execute daily via cron job that does 3 things:

  1. Fetches a webpage (http://services.runescape.com/m=clan-home/clan/Quest%20Cape%20FTW)
  2. Parses out the contents of 5 DIVs
  3. Stores the value of these DIVs into 5 variables that can then be accessed by my other web pages.

So far:

  1. I know how to fetch a webpage with file_get_contents('http://services.runescape.com/m=clan-home/clan/Quest%20Cape%20FTW');
  2. I don't know how to separate out just the desired DIVs (#Clanstat_1 .clanstatVal to #Clanstat_5 .clanstatVal)
  3. I know how to make the variables i.e. $var1, $var2, etc.

Can anyone help with step 2?

Was it helpful?

Solution

You can use any great HTML Parser written in PHP.

Personally, I like this one - PHP Simple HTML DOM Parser: http://simplehtmldom.sourceforge.net/

You can then access any element of your HTML using jQuery-like syntax.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top