Find Links in a webpage ..
Posted: Sun Nov 01, 2009 2:21 pm
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 !!
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 !!