[Tutor] regex woes in finding an ip and GET string

Válas Péter sulinet at postafiok.hu
Sun Jun 19 15:43:40 CEST 2011


2011/6/19 Gerhardus Geldenhuis <gerhardus.geldenhuis at gmail.com>

>   f = open(filename,'r')
>   filecontents = f.read()
>
Try f.read().splitlines() instead.



>   tuples = re.findall(r'^(\d+\.\d+\.\d+\.\d+).*\"GET(.*)HTTP',
> filecontents)
>
This searches the beginning of the lines, but you downloaded the whole page
as one string.

Another hint is to open it in an editor and investigate it by your eyes,
where are the strings you look for. :-)
Péter
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20110619/44cea578/attachment.html>


More information about the Tutor mailing list