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


Groups > comp.lang.python > #68257

Re: beautiful soup get class info

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.mixmin.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!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.005
X-Spam-Evidence '*H*': 0.99; '*S*': 0.00; 'python,': 0.02; 'problem:': 0.07; '22,': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'url:software': 0.09; 'argument.': 0.16; 'received:80.91.229.3': 0.16; 'received:97': 0.16; 'received:plane.gmane.org': 0.16; 'subject:class': 0.16; 'wrote:': 0.18; 'thanks.': 0.20; 'header:User-Agent:1': 0.23; 'fine': 0.24; "haven't": 0.24; 'code:': 0.26; 'header:X-Complaints-To:1': 0.27; 'header:In-Reply-To:1': 0.27; 'code': 0.31; 'workaround': 0.31; 'but': 0.35; 'christopher': 0.36; 'date.': 0.36; 'from:addr:live.com': 0.36; 'in:': 0.36; 'to:addr:python-list': 0.38; 'pm,': 0.38; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'march': 0.61; 'email addr:gmail.com': 0.63; 'worth': 0.66; 'here': 0.66; 'believe': 0.68; 'results': 0.69; 'subject:get': 0.81; "'class'": 0.84
X-Injected-Via-Gmane http://gmane.org/
To python-list@python.org
From Christopher Welborn <cjwelborn@live.com>
Subject Re: beautiful soup get class info
Date Tue, 11 Mar 2014 21:04:13 -0500
References <e73d29eb-17bb-472e-bdc4-c38ca904c60f@googlegroups.com>
Mime-Version 1.0
Content-Type text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding 8bit
X-Gmane-NNTP-Posting-Host 97-82-32-107.dhcp.mtgm.al.charter.com
User-Agent Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.3.0
In-Reply-To <e73d29eb-17bb-472e-bdc4-c38ca904c60f@googlegroups.com>
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.8069.1394589869.18130.python-list@python.org> (permalink)
Lines 33
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1394589869 news.xs4all.nl 2830 [2001:888:2000:d::a6]:51960
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:68257

Show key headers only | View raw


On 03/06/2014 02:22 PM, teddybubu@gmail.com wrote:
> I am using beautifulsoup to get the title and date of the website.
> title is working fine but I am not able to pull the date. Here is the code in the url:
>
>   <span class="date">October 22, 2011</span>
>
> In Python, I am using the following code:
> date1 = soup.span.text
> data=soup.find_all(date="value")
>
> Results in:
>
> []
> March 5, 2014
>
> What is the proper way to get this info?
> Thanks.
>

I believe it's the 'attrs' argument.
http://www.crummy.com/software/BeautifulSoup/bs4/doc/

# Workaround the 'class' problem:
data = soup.find_all(attrs={'class': 'date'})

I haven't tested it, but it's worth looking into.

-- 
\¯\      /¯/\
  \ \/¯¯\/ / / Christopher Welborn (cj)
   \__/\__/ /  cjwelborn at live·com
    \__/\__/   http://welbornprod.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