RE: [PHP] Extracting urls from HTML
| From: | David Snowden | Date: | Thu, 26 Oct 2000 17:36:12 +0000 |
| Subject: | RE: [PHP] Extracting urls from HTML | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-22176@lists.php.net to get a copy of this message | ||
Is there somewhere i can grab a script that does this from beginning to end?
thanks,
Dave
-----Original Message-----
From: Jay Greenspan [mailto:jay@trans-city.com]
Sent: Wednesday, October 25, 2000 6:58 PM
To: php-general@lists.php.net
Subject: Re: [PHP] Extracting urls from HTML
I think I'd use preg_match_all(). You can see the manual
for how it breaks up the array, which is pretty clost to what you're
looking for.
Something like this regular expression should work, I think.
You might have to make changes depending on how you
delimit your hrefs.
preg_match_all('/<a href="([^"]*)".*>(.*)<\/a>/i', $str,
$array);
"Srinivasan Ramakrishnan" wrote in message
<006d01c03edd$ef752420$ce87c5cb@srinivarmd3>...
>Hi,
>
>I need to extract the list of links from a html file.
>
>Ideally I will get them into an associative array where the name part
equals
>the text between <a href...> and </a>, and the value part contains the
>actual URL.
>
>I've been looking at the available string functions, and I can't seem to
>find a way. Is there a class or library that does this?
>
>I'm too lazy to figure out how to write a parser for this, atleast what I'm
>trying to do doesn't warrant that kind of effort. I have a pretty large
>bookmark file, and I want to store just the links and names in a text file.
>
>Thanks,
>
>Srini
>
>
>--
>PHP General Mailing List (http://www.php.net/)
>To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
>For additional commands, e-mail: php-general-help@lists.php.net
>To contact the list administrators, e-mail: php-list-admin@lists.php.net
>
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
For additional commands, e-mail: php-general-help@lists.php.net
To contact the list administrators, e-mail: php-list-admin@lists.php.net