Re: Extract printable text from web page using preg_match
| From: | M5 | Date: | Wed, 28 Feb 2007 07:09:14 +0000 |
| Subject: | Re: Extract printable text from web page using preg_match | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-249574@lists.php.net to get a copy of this message | ||
On 27-Feb-07, at 1:44 PM, Richard Lynch wrote:
On Tue, February 27, 2007 11:47 am, M5 wrote:No, it's not a very good solution. Striptags will leave everything within <head>, <style> and <script> (in the body or out). Comments are also included. I know it's possible to use non reg-ex strpos/substr to extra everything within <body>, but as another poster correctly said, this assumes a consistent HTML document (which there is not). I realize now that such a regex would be rather sophisticated, but I thought surely it must exist, since text-scrapping the readable content of a web page must not be rare.I am trying to write a regex function to extract the readable (visible, screen-rendered) portion of any web page. Specifically, I only want the text between the <body> tags, excluding any <script> or <style> tags within the document, also excluding comments. Has anyone here seen such a regex? Is it possible to do in one expression?I think http://php.net/striptags may be your best bet...
--Some people have a "gift" link here. Know what I want? I want you to buy a CD from some starving artist. http://cdbaby.com/browse/from/lynch Yeah, I get a buck. So? --PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php