Re: EXTRACTING URL FROM A FILE
| From: | _lallous | Date: | Mon, 17 Sep 2001 15:32:38 +0000 |
| Subject: | Re: EXTRACTING URL FROM A FILE | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-67606@lists.php.net to get a copy of this message | ||
your regexp won't work...you have to change it! cause a quick look to
yahoo's index page:
<a href=r/f3>Photos</a> - <a href=r/dr><b>Domain
Registration</b></a> -
see?!
I made this regexp which is partially working:
$re = "/<a href=(['\"]*|)(.+?)(\1|[ ])[^>]*>(.+?)<\/a>/is";
"Chinmay Varma" <chinmayvarma@rediffmail.com> wrote in message
news:20010917101835.13911.qmail@mailweb21.rediffmail.com...
Hi all,
The following is a sample code I try to extract URL from a Web Page.Its not
finding any match.Any idia why ?
Kindly let me know.
Thanks to all.
chinmay.
***********************************************************
$fp = fopen('http://yahoo.com/','r') or die
("Cannot connect");
while($line = fgets($fp,1024))
{
if(preg_match_all('/<.*?a.*?href=\s*?[\'"](.+)[\'"].*?>.*?<\/.*?a.*?>/i',$li
ne,$matches))
{
array_shift($matches);
foreach($matches as $match)
{
$url_list = $match;
echo $match;
}
}
}
********************************************************