Convert Tag type to String

3,359 views
Skip to first unread message

lucas kauffman

unread,
Sep 24, 2011, 6:33:00 AM9/24/11
to beautifulsoup
I have a tag type object :

for row in soup.findAll('tr'):
for data in row.findAll('td'):
if data.string and 'lucas' in data.string:
returnArray.append( row )
return returnArray

I want to use the row as a string to be able to append it to
something, but how to I do this ?

Leonard Richardson

unread,
Sep 24, 2011, 9:16:34 AM9/24/11
to beauti...@googlegroups.com

Tou can call str() or unicode() on a Tag object to get the
corresponding HTML markup.

Leonard

lucas kauffman

unread,
Sep 24, 2011, 9:17:10 AM9/24/11
to beauti...@googlegroups.com
Thanks, that fixed it :) 

2011/9/24 Leonard Richardson <leon...@segfault.org>

--
You received this message because you are subscribed to the Google Groups "beautifulsoup" group.
To post to this group, send email to beauti...@googlegroups.com.
To unsubscribe from this group, send email to beautifulsou...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/beautifulsoup?hl=en.


Reply all
Reply to author
Forward
0 new messages