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


Groups > comp.lang.python > #67974

Re: beautiful soup get class info

From Mark Lawrence <breamoreboy@yahoo.co.uk>
Subject Re: beautiful soup get class info
Date 2014-03-07 01:48 +0000
References <e73d29eb-17bb-472e-bdc4-c38ca904c60f@googlegroups.com> <lfanh4$mna$1@reader1.panix.com> <ae5b837c-501d-498e-bd3a-3b2c709c42b0@googlegroups.com> <lfaspm$998$1@reader1.panix.com> <c303cbad-d790-43ce-a88d-2068ec8e371c@googlegroups.com>
Newsgroups comp.lang.python
Message-ID <mailman.7886.1394156960.18130.python-list@python.org> (permalink)

Show all headers | View raw


On 07/03/2014 01:37, teddybubu@gmail.com wrote:
> On Thursday, March 6, 2014 4:28:06 PM UTC-6, John Gordon wrote:
>> In <ae5b837c-501d-498e-bd3a-3b2c709c42b0@googlegroups.com>  writes:
>>
>>
>>
>>>> soup.find_all(name="span", class="date")
>>
>>
>>
>>> I have python 2.7.2 and it does not like class in the code you provided.
>>
>>
>>
>> Oh right, 'class' is a reserved word.  I imagine beautifulsoup has
>>
>> a workaround for that.
>>
>>
>>
>>> Now when I take out [ class="date"], this is returned:
>>
>>>     [<span class="date">March 5, 2014</span>, <span class="date">March 5, 2014</span>]
>>
>>>
>>
>>> This is the code I am using: "data = soup.find_all(name="span")
>>
>>> print (data)"
>>
>>> 1. it returns today's date instead of the actual date
>>
>>> 2. returns it twice
>>
>>
>>
>> Are there two occurrences of '<span class="date">March 5, 2014</span>'
>>
>> in the HTML?  If so, then beautifulsoup is doing its job correctly.
>>
>>
>>
>> It might help if you posted the sample HTML data you're working with.
>>
>>
>>
>> --
>>
>> John Gordon         Imagine what it must be like for a real medical doctor to
>>
>>     watch 'House', or a real serial killer to watch 'Dexter'.
>
> ok I got this working. now to the next problem.... thanks.
>

I'm pleased to see that you have a solution.  Now, should you wish to 
ask further questions, would you please read and action this first 
https://wiki.python.org/moin/GoogleGroupsPython to prevent us seeing the 
double line spacing above, thanks.

-- 
My fellow Pythonistas, ask not what our language can do for you, ask 
what you can do for our language.

Mark Lawrence

---
This email is free from viruses and malware because avast! Antivirus protection is active.
http://www.avast.com

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


Thread

beautiful soup get class info teddybubu@gmail.com - 2014-03-06 12:22 -0800
  Re: beautiful soup get class info John Gordon <gordon@panix.com> - 2014-03-06 20:58 +0000
    Re: beautiful soup get class info teddybubu@gmail.com - 2014-03-06 13:38 -0800
      Re: beautiful soup get class info John Gordon <gordon@panix.com> - 2014-03-06 22:28 +0000
        Re: beautiful soup get class info teddybubu@gmail.com - 2014-03-06 17:37 -0800
          Re: beautiful soup get class info Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-03-07 01:48 +0000
  Re: beautiful soup get class info Christopher Welborn <cjwelborn@live.com> - 2014-03-11 21:04 -0500
  Re: beautiful soup get class info Peter Otten <__peter__@web.de> - 2014-03-12 08:36 +0100

csiph-web