Jump to content

Reading HTML source and finding specific URL's


Kairu

Recommended Posts

Ok! I have a new project starting and I need a little help.

 

I am creating some images that will change what they display depending on what is in a database. To populate it, I am having users input their username. (This is on a forum)

 

The user will click to a PHP page, which will ask for their username. I want to take the username, and retrieve the source from the page "http://www.gaiaonline.com/p/<username>".

 

I then need to search out the string "/forum/searchposts/" and take the numbers after it, convert them into hex, and then search for the first URL containing that hex value.

 

I dont know where to start with grabbing the source. Or searching within it.

 

The rest I can probably handle.

Well, I finished something that works. I dont know if it is that productive, as it takes a while to finish.

 

Anyone see any improvements I can make?

 

<?php
$search = 'http://www.gaiaonline.com/p/' . $_GET['u'];
$content =  file_get_contents($search);
$array = split('"', $content);

for($i=0; $i<=count($array); $i++)
{
    if(ereg("/forum/searchposts/", $array[$i]) != false || ereg("/forum/myposts/", $array[$i]) != false)
    {
        $temp = $array[$i];
    }
}
$temp = explode('/', $temp);
$ID = $temp[3];

$HEX = dechex($ID);

for($i=0; $i<=count($array); $i++)
{
    if(ereg($HEX, $array[$i]) != false)
    {
        $URL = $array[$i];
    }
}

?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.