Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #68257
| From | Christopher Welborn <cjwelborn@live.com> |
|---|---|
| Subject | Re: beautiful soup get class info |
| Date | 2014-03-11 21:04 -0500 |
| References | <e73d29eb-17bb-472e-bdc4-c38ca904c60f@googlegroups.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.8069.1394589869.18130.python-list@python.org> (permalink) |
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 | Next — Previous in thread | Next in thread | Find similar | Unroll 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