Jump to content

Pulling text from an external html file (not runescape!)


Mercifull

Recommended Posts

Ok so ive got a page on my webserver which dynamicly generates statistics in the following style:

 

 

 

total=0;good=0;views=0;edits=0;users=0;admins=0;images=0;jobs=0 

where 0 is a number between 0 and well.. infinite really but no more than a 7 digit number really.

 

 

 

 

 

 

 

I want to be able to pull the total number from this file and display it on another php page using cURL or file_get_contents but im totally lost by it and cant find a tutorial thats any good for me.

 

 

 

 

 

 

 

I want the number between total= and ;good=....etc anod nothing else so I need to strip all the other stuff.

 

 

 

 

 

 

 

I worked out how to use file_get_contents to get a certain number of characters after a string such as total= but because I cant guarantee what the length of the number is the script varies between 13337 (total=13337;good=....) and 96;go (total=96;good=....)

 

 

 

 

 

 

 

I need the script to start after total= but stop before ;good= Some help would be really appreciated :)

612d9da508.png

Mercifull.png

Mercifull <3 Suzi

"We don't want players to be able to buy their way to success in RuneScape. If we let players start doing this, it devalues RuneScape for others. We feel your status in real-life shouldn't affect your ability to be successful in RuneScape" Jagex 01/04/01 - 02/03/12

Link to comment
Share on other sites

Well im not an expert on this. All i know is that I need to pull off a number from a file this file and display the figure somewhere else.

612d9da508.png

Mercifull.png

Mercifull <3 Suzi

"We don't want players to be able to buy their way to success in RuneScape. If we let players start doing this, it devalues RuneScape for others. We feel your status in real-life shouldn't affect your ability to be successful in RuneScape" Jagex 01/04/01 - 02/03/12

Link to comment
Share on other sites

Ah, the wiki; hrm.

 

 

 

 

 

 

 

Well, you could fetch all the text, explode using ; for the delimeter and str replace a-z and = with null value then you'll be left with your integer values only in the array.

Link to comment
Share on other sites

Im not going to pretend i know what im talking about here, Rick, so some links for help would be good lol

612d9da508.png

Mercifull.png

Mercifull <3 Suzi

"We don't want players to be able to buy their way to success in RuneScape. If we let players start doing this, it devalues RuneScape for others. We feel your status in real-life shouldn't affect your ability to be successful in RuneScape" Jagex 01/04/01 - 02/03/12

Link to comment
Share on other sites

<?php



$urlofstats = "rawstats.txt";



$rawstats = file_get_contents($urlofstats);







$num_values = explode(";", $rawstats);







$remove = array("a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","=");



foreach($num_values as $x => $value)



{



  $num_values[$x] = str_replace($remove, "", $value);



}







/* print out the values and [cabbage] */







foreach($num_values as $value)



{



  echo $value."

";



}



?>

Link to comment
Share on other sites

Thanks to Rick here is the final code I used:

 

 

 

 

 

 

 

<?php



$urlofstats = "http://en.battlestarwiki.org/wiki/Special:Statistics?action=raw";



$rawstats = file_get_contents($urlofstats);







$num_values = explode(";", $rawstats);







$remove = array("a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","=");



foreach($num_values as $x => $value)



{



  $num_values[$x] = str_replace($remove, "", $value);



}







echo $num_values[1];







?>

612d9da508.png

Mercifull.png

Mercifull <3 Suzi

"We don't want players to be able to buy their way to success in RuneScape. If we let players start doing this, it devalues RuneScape for others. We feel your status in real-life shouldn't affect your ability to be successful in RuneScape" Jagex 01/04/01 - 02/03/12

Link to comment
Share on other sites

In action on the front page of the Battlestar Wiki

 

 

 

Cheers Rick.

612d9da508.png

Mercifull.png

Mercifull <3 Suzi

"We don't want players to be able to buy their way to success in RuneScape. If we let players start doing this, it devalues RuneScape for others. We feel your status in real-life shouldn't affect your ability to be successful in RuneScape" Jagex 01/04/01 - 02/03/12

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.