View Full Version : Need script to add to url to click link on page

06-03-2009, 04:56 PM
Ok ...
I am actually working on a Phpbb forum for members of an online game I play.
I am trying to make custom BBcode tags to access things in my game with no success!

Here is the thing ...
In this game, there are players and tribes (groups of players).
I am unable to link to the player/tribe pages directly with a url using the names because the database and pages for them are linked by numbers.
ie: each player/tribe name corresponds to a database entry number and you can only use numbers in the URL.
Player: Powrpak
URL: http://en23.tribalwars.net/page.php?page=inbound&screen=info_player&id=3833804
please note the id=3833804 ..


In trying to work a way around this, here is what I can think of ...

I have found a page that will bring up a player info screen I can use!
All I do is edit the last variable (searchstring=)with the player name!

Same with the tribe info screen.
http://www.twstats.com/en23/index.php?page=rankings&mode=tribes&searchstring=EKC 3
I just edit the same variable in this one as well

Here is the problem ...
Hopefull there is an option using a script in the URL . . .

If you go to either of these pages, you will see it has found the requested info ..
To GO to the info, you need to click the link with the name of what you searched for.
I need to make a URL with scripting in it to not only GO to this url listed above
but hopefully click the link on the page FOR the player/tribe I searched for!!

I dont know the coding but here is my thoughts . . .
The player name variable used in the link itself might be the key I would think.
If you can make the script search the page for a link with the same variable and click that then that solves the problem!
ie: Player name searched for was "Powrpak" so have the script look for a link named "Powrpak" on the page loaded and click it!

Any help with this would be GREATLY appreciated!!

You can test it using the following variables:
Players: Powrpak / DrgonWhere / Missfit69
Tribes: EKC 3 / PLG / EKC3-1
If they all work then we have a solution!!

06-03-2009, 05:15 PM
umm ... I know this might be asking alot ...
BUT . . .

If the above is possible ...
Is it possible to link through 3 pages??

Ie: the script itself goes to the link I provided above . . .
THEN it clicks the link to go to the actual info page for the player/tribe. . .
THEN it clicks the link on THAT page called "TW.Net"

I'm thinking this is probably too much to ask and isnt possible!
BUT .. If it is, I will be a very happy camper .. lol
Because THAT page is the one I have needed to get to all along .. hehehe

06-06-2009, 01:28 AM
Umm .. no-one has any ideas or can at least tell me if it's possible??

06-08-2009, 05:11 AM
Starting to wonder if there is any point posting in this forum??

If it isnt possible, at least someone could post THTA!!

Old Pedant
06-08-2009, 06:34 AM
You posted on *SUNDAY* (at least here in the USA). When relatively few people are active.

Anyway, pardon me, but if you have the source code for this game (and you must, if it's written in standard PHP, no?), why not simply change the code in that page you noted:

Fix it so that it will accept a name instead:

Just change the PHP code so that it looks for id and, if not found, looks for name and then makes the DB query using name instead of id.

Almost surely not more than 3 to 5 lines of PHP code would need changing.

Much simpler than trying to fix it with workarounds in JS code.

Old Pedant
06-08-2009, 06:43 AM
Hmmm...is it possible that this BB of yours is *NOT* on the same server as the game?? That is, you aren't really able to change the PHP code because it's not your server and not your code?

If so, then maybe the best way to do this is to "screen scrape" using that page you noted.

That is, you make an AJAX-style request of that page and it returns the full HTML of that page and then you look inside that HTML for the needed id number and then make the actual request using the number.

Yeah...that doesn't look too hard to do.

If you look at that page
and do a VIEW-->>SOURCE of the HTML, you will see this line:

<a href="index.php?page=player&amp;id=3833804">Powrpak</a>

SO it wouldn't be hard at all to get the HTML and look through it for that pattern and pull out the id= value.

The only caveat here is that this twstats.com fellow may block requests that aren't coming from browsers. Even that's probably not too hard to bypass, by making sure you set the right REQUEST parameters when you make the AJAX-style request.

I'd imagine you could get this working in one to three hours of work. Unless there is something unexpected that crops up.

06-13-2009, 11:14 PM
Ok ...
The first option given is not available to me as I dont have access to the code and,no, the forum is not on same server as the game!

Second option would require ALOT more skill then I have .. lol
At least I am honest!!

How about this . . .
There is a page I can go to that has a form!
I will post the source of the page!
Can someone fix me a link that will go to that page and input the form data and hit submit!!
This would likely be alot easier!!

Here is the key source from the page!

<form action="/game.php?screen=ranking&amp;mode=player&amp;search" method="post">
Search: <input name="name" type="text" value="" size="20" />
<input type="submit" value="OK" />

Here is the Page address:
(You cant likely access it as you must be a player and logged in for the link to work)

Like I said .. if I can get a URL that will go to this address, insert the form data and submit it .. I AM SET!!
Sorry to be a pain but I have to find some way around this!