Forum Moderators: coopster

Message Too Old, No Replies

Grabbing code from one page.

         

Saikou

8:55 pm on Aug 13, 2006 (gmt 0)

10+ Year Member



Been awhile since I've visited, but once again, I'm stumped. -.-

A friend of mine recently requested a script that retrieves clan member's levels from a game's high score table. Many people have suggested using cURL, file_get_contents(), and preg_match_all()...But, I have no idea how to use these. =S

Basically, I need to grab the 'Level' column from this page: <snip>

Substituting 'saikou_xl' with a username submitted via a form (already got that part finished, just can't grab the Level column by itself...)

Any help would be MUCH appreciated. :)

[edited by: trillianjedi at 9:47 pm (utc) on Aug. 13, 2006]
[edit reason]
[1][edit reason] No specific URL's please as per TOS... [/edit]
[/edit][/1]

jatar_k

5:23 pm on Aug 14, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



file_get_contents would be fine to read the page into a variable then you need to parse through that to get the info you need.

You could use one of the Regular Expression Functions [php.net]

Saikou

2:50 am on Aug 17, 2006 (gmt 0)

10+ Year Member



Okay...I came up with some..rather...unique ideas of my own to read the file into a page, but I'm having trouble extracting a certain part. Let's say my code is this:

<body>
.
.
.
<table border="0" class="raisepagesmall">
{data}
</table>
.
.
.
</body>

Now, the {data} represents about 30 segments of this type of code:

<tr>
<td></td>
<td align="left"><a href="overall.ws?table=0&user=saikou_xl">Overall</a></td>
<td align="right">68,572</td>
<td align="right">1397</td>
<td align="right">14,438,773</td>
</tr>

The only problem is that the 3 <td> lines will change periodically. How can I search for that specific body of code, and on top of that, how can I be sure it will pull the variables with it?

I'm so confused. >.<

coopster

2:50 pm on Aug 22, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



How about just searching for the opening and closing <table> element and parsing the information within them?