Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #54030

Parsing an html line and pulling out only numbers that meet a certain criteria

Newsgroups comp.lang.python
Date 2013-09-11 20:03 -0700
Message-ID <d9a020cc-89eb-4cb4-b884-abe156f18d33@googlegroups.com> (permalink)
Subject Parsing an html line and pulling out only numbers that meet a certain criteria
From Cory Mottice <cmottice@gmail.com>

Show all headers | View raw


I am using line.rfind to parse a particular line of html code. For example, this is the line of html code I am parsing:

<strong class="temp">79<span>&deg;</span></strong><span class="low"><span>Lo</span> 56<span>&deg;</span></span>

and this is the code I use to split the line to (in this case) pull out the '79'.

position0 = line.rfind('{}'.format(date1.strftime("%a")))
if position0 > 0 :
        self.high0 = lines[line_number + 4].split('<span>')[0].split('">')[-1]

Now I need to only pull out that number if it is >=94 and <=37. If it does not meet this criteria, I don't want anything to happen. Any ideas? Thank you in advance!

Back to comp.lang.python | Previous | NextNext in thread | Find similar | Unroll thread


Thread

Parsing an html line and pulling out only numbers that meet a certain criteria Cory Mottice <cmottice@gmail.com> - 2013-09-11 20:03 -0700
  Re: Parsing an html line and pulling out only numbers that meet a certain criteria John Gordon <gordon@panix.com> - 2013-09-12 05:40 +0000
  Re: Parsing an html line and pulling out only numbers that meet a certain criteria Dave Angel <davea@davea.name> - 2013-09-12 10:36 +0000

csiph-web