SRL Archive - General

[PHP] Request


TViYH

2008-02-15 13:34:53

I need something like a RuneScape Online Players grabber, but I need to grab the amount of posts a thread has on a certain forum…Any help?

Timer

2008-02-15 13:51:03

why php, just use a scar script?

ShowerThoughts

2008-02-15 14:06:51

yeah use srl, this function is special for it

StatsGrabberMAdeForelkins;

try it maybe… xD

Timer

2008-02-15 14:21:52

procedure StatsGrabberMadeForElkins;
var
PageContent: string;
begin
PageContent := GetPage('http://www..com');
PageContent := Between('somthing', 'sonthing', PageContent);
Writeln(PageContent);
end;

TViYH

2008-02-15 14:30:07

I want to echo it onto the page via HTML is why…
I'm not a good PHP scripter…I want a page that grabs a simple post number and echoes it…


EDIT: Timer, for between in SCAR, does it mean between the html code? or just the shown text.?

Timer

2008-02-15 14:34:36

between…
begin
Writeln(getpage('http://www..com');
end.

TViYH

2008-02-15 14:42:41

-.- You didn't answer my question. Does it retrieve what is between the visible text on that page, or between the HTML code inside it.

Timer

2008-02-15 14:43:34

idk, just run that, you'll see!! lol

TViYH

2008-02-15 14:53:03

Ok, so now I have it to where it retrieves the stuff…But now I need to make it into a website…

ShowerThoughts

2008-02-15 15:56:42

dude this SRL-FORUMS not CRAZY-ELKINS IDEA FORUMS

TViYH

2008-02-15 16:06:58

It's also a request forum. I don't admire your post.

Garrett

2008-02-15 21:22:31

Well.. I would help, but I don't exactly know what you need.

Ok, so now I have it to where it retrieves the stuff…But now I need to make it into a website…


So you need something like the echo(); command?
or just you need to know how to setup a webpage with php?

TViYH

2008-02-16 00:33:54

I need to know how to make PHP grab text between two words on a website, and echo them.

Garrett

2008-02-16 01:12:06

Ah.. ok, well I have a function for that already:

[PHP]function str_between($str, $betw, $betw2)
{
$str = " " . $str;
$pos = strpos($str, $betw);
if ($pos > 0)
{
$str2 = substr($str, $pos + strlen($betw));
$pos2 = strpos($str2, $betw2);
if ($pos2 == 0)
return '';
return substr($str2, 0, $pos2);
}
else
{
return '';
}
}[/PHP]

TViYH

2008-02-16 01:29:05

Would this work then?:

[PHP]<?php

function str_between($str, $betw, $betw2)
{
$str = " " . $str;
$pos = strpos($str, $betw);
if ($pos > 0)
{
$str2 = substr($str, $pos + strlen($betw));
$pos2 = strpos($str2, $betw2);
if ($pos2 == 0)
return '';
return substr($str2, 0, $pos2);
}
else
{
return '';
}
}

$users = str_between('http://srl-forums.com/forum/','<a href="online.php" rel="nofollow">','<a href="online.php" rel="nofollow">Currently Active Users</a>','</div></div>');
echo $users;

?>[/PHP]

Garrett

2008-02-16 10:33:50

That wouldn't… you have to do a file_get_contents to get a webpage.

I tested this, and it works:
[PHP]<?php

function str_between($str, $betw, $betw2)
{
$str = " " . $str;
$pos = strpos($str, $betw);
if ($pos > 0)
{
$str2 = substr($str, $pos + strlen($betw));
$pos2 = strpos($str2, $betw2);
if ($pos2 == 0)
return '';
return substr($str2, 0, $pos2);
}
else
{
return '';
}
}

$site = file_get_contents('http://srl-forums.com/forum/');
$users = str_between($site, 'Currently Active Users</a>:', '
</td>');
echo $users;

?> [/PHP]

Harry

2008-03-07 20:43:17

Gravedig, sorry, my post is worth it ;)

Botmaster has a player grabber, check it out - is that what you mean?

Wizzup?

2008-03-08 05:51:20

He just wants to print the online players on a HTML page…
Not that hard in PHP. :)