[Tutor] HTML Parsing

linuxian iandsd pylinuxian at gmail.com
Mon Apr 21 18:02:33 CEST 2008


Another horrid solution


> #!/usr/bin/python
> # line number does not change so we use that

# the data we're looking for does not have a (unique) close tag (htmllib
> ????)
>
> import re, urllib2
> file=urllib2.urlopen('http://10.1.2.201/server-status')
> n=0
> for line in file:
>  n=n+1
>  if n==16:
>   print re.sub('requests.*','',line)[4:].strip()
>  elif n==17:
>   print re.sub('requests.*','',line)[4:].strip()
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/tutor/attachments/20080421/eda74bce/attachment.htm 


More information about the Tutor mailing list