Re: Extract printable text from web page using preg_match

From: Date: Wed, 28 Feb 2007 08:48:44 +0000
Subject: Re: Extract printable text from web page using preg_match
References: 1 2 3  Groups: php.general 
Request: Send a blank email to php-general+get-249580@lists.php.net to get a copy of this message
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. Said it before, but low-tech solution is to use program "lynx" with the -dump argument and capture the output back to PHP. I'm assuming you are on Linux or OSX I guess as I've not heard of using lynx on windows..... There are loads of command line options to control the way lynx displays the output so you have a very fine grain of control here. Col

« previous php.general (#249580) next »