Trouble with regex
Fernando
iscaris at hotmail.com
Tue Dec 31 11:24:52 EST 2002
I'm writing a regex to retrieve all the links in a google result page,
but I'm only geting the first one.
Here's some sample code:
import re, urllib
urllib.URLopener.version = "Mozilla/4.0 (compatible; MSIE 6.0; Windows
NT 5.0)"
# result page with 2 links
data = urllib.urlopen('http://www.google.com/search?sourceid=navclient&q=diodenorl').read()
#here's the regex
p = re.compile('<p class=g><a href=([0-9a-zA-Z.:/_-]{1,})')
d = p.search(data)
d.groups()
>('http://www.viruete.com/articulos/gauntlet.htm',)
I only get the first one. How can I get all the occurrences of this
regex?
TIA
More information about the Python-list
mailing list