webspider, regexp not working, why?

Reedick, Andrew jr9445 at ATT.COM
Fri May 23 13:26:31 EDT 2008



> -----Original Message-----
> From: python-list-bounces+jr9445=att.com at python.org [mailto:python-
> list-bounces+jr9445=att.com at python.org] On Behalf Of
> notnorwegian at yahoo.se
> Sent: Friday, May 23, 2008 12:43 PM
> To: python-list at python.org
> Subject: webspider, regexp not working, why?
> 
> url = re.compile(r"^((ht|f)tp(s?)\:\/\/|~/|/)?([\w]+:\w+@)?([a-zA-Z]
> 
> search and match yields the same results.
> 
> but when you put something like href= in front of it it doesnt work.


a)  '^' matches at the beginning of a line.  So if 'href=' is at the
beginning of the line...

b)  Regexes are hard enough to read as is.  (http|ftp|https) is more
readable than ((ht|f)tp(s?).

c)  If you're going to parse html/xml then bite the bullet and learn one
of the libraries specifically designed to parse html/xml.  Many other
regex gurus have learned this lesson.  Myself included.  =)



*****

The information transmitted is intended only for the person or entity to which it is addressed and may contain confidential, proprietary, and/or privileged material. Any review, retransmission, dissemination or other use of, or taking of any action in reliance upon this information by persons or entities other than the intended recipient is prohibited. If you received this in error, please contact the sender and delete the material from all computers. GA621





More information about the Python-list mailing list