beautiful soup get class info
Christopher Welborn
cjwelborn at live.com
Tue Mar 11 22:04:13 EDT 2014
On 03/06/2014 02:22 PM, teddybubu at 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
More information about the Python-list
mailing list