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.

Link to comment
Share on other sites

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];
    }
}

?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.