Page 1 of 1

Find Links in a webpage ..

Posted: Sun Nov 01, 2009 2:21 pm
by ved2210
Hi friends ,
I am having trouble with finding all the links in a webpage .
My problem is to find all " href " tags and with the help of that i want to
calculate and display all the links of a particular html webpage .
After finding the Links i want to calculate the number of inbound and out bound links
of a webpage .



The task is like this :-

say some links <a href = http:// something.html >somthing </a>

i want to take out the something.html from that link .

I have tried something like this :-


<?php

function only_links($var)
{

echo $var;
$str=$var ;
$str=preg_match("/href='([^']*)'/", $str, $regs);
$new_str= $regs[1];
$var=substr($new_str,7,strlen($new_str));

return($var);

}


$fh=file("index.html");
array_filter($fh,"only_links");
print_r($fh);


?>





Please help me with that . I am having very less time and i have to submit my assignment
tomorrow . I tried very hard but i think i am not smart enough to deal with it !! :roll:

Re: Find Links in a webpage ..

Posted: Sun Nov 01, 2009 3:25 pm
by ved2210
Can you give me some suggestion with the code i have written !!

Thanks

Re: Find Links in a webpage ..

Posted: Sun Nov 01, 2009 5:36 pm
by ved2210
Hi ,
I got your point .
And i have made changes according to your instruction .
I am glad that my code is running fine now . [:)]

Thank you so much for your help .
I really appreciate your help .

Thanks Again ,
Ved.