Follow us on Twitter!
I'd prefer to die standing, than to live on my knees - Che Guevara
Thursday, April 24, 2014
Navigation
Home
HellBoundHackers Main:
HellBoundHackers Find:
HellBoundHackers Information:
Learn
Communicate
Submit
Shop
Challenges
HellBoundHackers Exploit:
HellBoundHackers Programming:
HellBoundHackers Think:
HellBoundHackers Track:
HellBoundHackers Patch:
HellBoundHackers Other:
HellBoundHackers Need Help?
Other
Members Online
Total Online: 16
Guests Online: 15
Members Online: 1

Registered Members: 82889
Newest Member: Geriztul
Latest Articles
View Thread

HellBound Hackers | Computer General | Programming

Author

Help taking data off page (Eg. Preg_Match() )

Flaming_figures
Member

Your avatar

Posts: 209
Location: ΦΠΥΔΓΙΦ
Joined: 28.06.06
Rank:
Apprentice
Posted on 04-10-08 20:43
Well, I've been trying to right a script for this clan I'm working for (gaming clan) and they play Americas Army. What I am trying to do, is go onto aaotracker.com take the Hours of a user and convert it into a variable. Now, I've been around PHP a long time, but I still have issues with preg match. Thus, I have tried to find ways around it.

Now, I want some help actually doing this... I don't care how it is done, as long as I end up with a number of their hours after $hours = ______

I have to use this number in some later scripts, which are really simple once I pull the hours. If you want to try out some preg_match/preg_match_all, here is the section of code I am trying to use.


Code
<tr>
    <td><font face="Verdana,Arial" size="2"><b>Total time played:</b></font></td>
    <td><font face="Verdana,Arial" size="2">2378.2 hours (1.5 hrs. per day)</font></td>
   </tr>





And of course, I would want a variable holding 2378.2 in it.

I did manage to find an XML file for a the clan wide. I have tried switches, but can't find a way to declare it a variable in the switch (I'll post it later) The XML file is here -> http://aaotracker.com/livefeed/xml_clanprofile.php?clanid=48882

And if it goes through XML, I would need Name, Tracker, Hours AND Honor set as variables.

This is the code I was trying to work with with the XML (my free little server doesn't let me use other URL's in fopen so I had to save a copy, but I should read the aaotracker xml file)

Code


$parser=xml_parser_create();


function start($parser,$element_name,$element_attrs)
  {
  switch($element_name)
    {
    case "PLAYERID":
    echo "Player ID: ";
    break;
    case "PLAYERNAME":
    echo "Name: ";
    break;
    case "PLAYERTIME":
    echo "Time: ";
    break;
    case "PLAYERHONOR":
    echo "Honor: ";
   break;
   default:
   echo "<!--";
    }
  }


function stop($parser,$element_name)
  {
  echo "<br />";
  }

function char($parser,$data)
  {
  echo $data;
  }


xml_set_element_handler($parser,"start","stop");


xml_set_character_data_handler($parser,"char");


$fp=fopen("test.xml","r");

while ($data=fread($fp,4096))
  {
  xml_parse($parser,$data,feof($fp)) or
  die (sprintf("XML Error: %s at line %d",
  xml_error_string(xml_get_error_code($parser)),
  xml_get_current_line_number($parser)));
  }

xml_parser_free($parser);






Please Help, and tyia... This script has been driving me crazy and I think I officially give up on preg_match 0_o


Author

RE: Help taking data off page (Eg. Preg_Match() )

spyware
Member



Posts: 4192
Location:
Joined: 14.04.07
Rank:
God
Warn Level: 90
Posted on 04-10-08 20:53
Did you read any RegEx tutorials? If not; go read one. If you still can't figure out how to do this, come back here and post what you've tried/where you're stuck.

Oh, and you know you have to use cURL to grab what you need right? You'll probably want to do this:

cURL page X, grab page source.
Use RegEx to find some numbers in the source of page X.
Store found numbers in variables.
Do something with the found data.



img507.imageshack.us/img507/3580/spynewsig3il1.png
"The chowner of property." - Zeph
[small]
Widespread intellectual and moral docility may be convenient for leaders in the short term,
but it is suicidal for nations in the long term.
- Carl Sagan
[center]�Since the grid is inescapable, what were the earlier lasers about? Does the corridor have a sense of humor?� - Ebert[/ce