[Tutor] printing the links of a page (regular expressions)
Alfonso
traviesomono at yahoo.es
Sat May 6 14:13:17 CEST 2006
I'm writing a script to retrieve and print some links of a page. These
links begin wiht "/dog/", so I use a regular expresion to try to find
them. The problem is that the script only retrieves a link per line in
the page. I mean, if the line hat several links, the script only reports
the first. I can't find where is the mistake. Does anyone hat a idea,
what I have false made?
Thank you very much for your help.
import re
from urllib import urlopen
fileObj = urlopen("http://name_of_the_page")
links = []
regex = re.compile ( "((/dog/)[^ \"\'<>;:,]+)",re.I)
for a in fileObj.readlines():
result = regex.search(a)
if result:
print result.group()
______________________________________________
LLama Gratis a cualquier PC del Mundo.
Llamadas a fijos y móviles desde 1 céntimo por minuto.
http://es.voice.yahoo.com
More information about the Tutor
mailing list