Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #54048
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!eweka.nl!lightspeed.eweka.nl!194.109.133.86.MISMATCH!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <python-python-list@m.gmane.org> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.004 |
| X-Spam-Evidence | '*H*': 0.99; '*S*': 0.00; 'assuming': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'temp': 0.16; 'typo': 0.16; 'wrote:': 0.18; 'code.': 0.18; 'split': 0.19; '(in': 0.22; 'header:User-Agent:1': 0.23; 'parse': 0.24; 'header:X-Complaints-To:1': 0.27; 'code': 0.31; 'subject:numbers': 0.31; 'subject:that': 0.31; 'there,': 0.34; 'but': 0.35; 'charset:us-ascii': 0.36; 'example,': 0.37; 'to:addr :python-list': 0.38; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'worry': 0.60 |
| X-Injected-Via-Gmane | http://gmane.org/ |
| To | python-list@python.org |
| From | Dave Angel <davea@davea.name> |
| Subject | Re: Parsing an html line and pulling out only numbers that meet a certain criteria |
| Date | Thu, 12 Sep 2013 10:36:24 +0000 (UTC) |
| References | <d9a020cc-89eb-4cb4-b884-abe156f18d33@googlegroups.com> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=US-ASCII |
| Content-Transfer-Encoding | 7bit |
| X-Gmane-NNTP-Posting-Host | 174.32.174.36 |
| User-Agent | XPN/1.2.6 (Street Spirit ; Linux) |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.15 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list/> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.309.1378982206.5461.python-list@python.org> (permalink) |
| Lines | 26 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1378982206 news.xs4all.nl 15897 [2001:888:2000:d::a6]:59361 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:54048 |
Show key headers only | View raw
On 11/9/2013 23:03, Cory Mottice wrote:
> 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>°</span></strong><span class="low"><span>Lo</span> 56<span>°</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!
Since no integer is both >=94 and <=37, you'd never have to worry about
it. But assuming there's a typo there,
temp = lines[line_number + 4.........
if 94 <= int(temp) <= 37:
self.high0 = temp
--
DaveA
Back to comp.lang.python | Previous | Next — Previous in thread | Find similar | Unroll 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