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


Groups > comp.lang.python > #108026

Re: Best way to clean up list items?

From DFS <nospam@dfs.com>
Newsgroups comp.lang.python
Subject Re: Best way to clean up list items?
Date 2016-05-02 14:09 -0400
Organization A noiseless patient Spider
Message-ID <ng84uj$emf$1@dont-email.me> (permalink)
References <ng7v9d$ld8$1@dont-email.me> <1462209930.1313497.595817481.73635112@webmail.messagingengine.com> <mailman.325.1462209932.32212.python-list@python.org>

Show all headers | View raw


On 5/2/2016 1:25 PM, Stephen Hansen wrote:
> On Mon, May 2, 2016, at 09:33 AM, DFS wrote:
>> Have: list1 = ['\r\n   Item 1  ','  Item 2  ','\r\n  ']
>
> I'm curious how you got to this point, it seems like you can solve the
> problem in how this is generated.

--------------------------------------------------------------------
from lxml import html
import requests

webpage = 
"http://www.usdirectory.com/ypr.aspx?fromform=qsearch&qs=TN&wqhqn=2&qc=Nashville&rg=30&qhqn=restaurant&sb=zipdisc&ap=2"

page  = requests.get(webpage)
tree  = html.fromstring(page.content)
addr1 = tree.xpath('//span[@class="text3"]/text()')
print 'Addresses: ', addr1
--------------------------------------------------------------------

I'd prefer to get clean data in the first place, but I don't know a 
better way to extract it from the HTML.


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


Thread

Best way to clean up list items? DFS <nospam@dfs.com> - 2016-05-02 12:33 -0400
  Re: Best way to clean up list items? Jussi Piitulainen <jussi.piitulainen@helsinki.fi> - 2016-05-02 19:57 +0300
    Re: Best way to clean up list items? justin walters <walters.justin01@gmail.com> - 2016-05-02 10:10 -0700
    Re: Best way to clean up list items? DFS <nospam@dfs.com> - 2016-05-02 14:06 -0400
      Re: Best way to clean up list items? Jussi Piitulainen <jussi.piitulainen@helsinki.fi> - 2016-05-02 21:27 +0300
        Re: Best way to clean up list items? DFS <nospam@dfs.com> - 2016-05-02 15:04 -0400
  Re: Best way to clean up list items? Stephen Hansen <me+python@ixokai.io> - 2016-05-02 10:25 -0700
    Re: Best way to clean up list items? DFS <nospam@dfs.com> - 2016-05-02 14:09 -0400
      Re: Best way to clean up list items? Stephen Hansen <me+python@ixokai.io> - 2016-05-02 11:23 -0700
  Re: Best way to clean up list items? Peter Otten <__peter__@web.de> - 2016-05-02 19:30 +0200

csiph-web