On 27-Feb-07, at 1:44 PM, Richard Lynch wrote:
On Tue, February 27, 2007 11:47 am, M5 wrote:
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...
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.
--
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
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php