BeautifulSoup - extract the <object tag

Marc 'BlackJack' Rintsch bj_666 at gmx.net
Mon Jun 18 14:49:10 EDT 2007


In <1182192028.173189.168910 at u2g2000hsc.googlegroups.com>, gcmartijn
wrote:

> I'm trying to extract something like this:
> 
> <object classid=clsid:D27CDB6E-AE6D-11cf-96B8-444553540000
> codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/
> swflash.cab#version=7,0,19,0" width=640 height=400>
> <param name=movie value=url>
> <param name=quality value=high><param name=SCALE value=showall>
> <embed src=url quality=highpluginspage=http://www.macromedia.com/go/
> getflashplayer type=application/x-shockwave-flash width=640 height=400
> bgcolor=#000000 scale= showall>
> </embed>
> </object>
> 
> ====
> I don't know how I can get the param
> 
> # below don't work
>     for test in soup.fetch('object'):
>         print test # nothing

There's no `fetch()`.

In [15]: soup.fetch('object')
---------------------------------------------------------------------------
exceptions.TypeError                      Traceback (most recent call last)

/home/new/<ipython console>

TypeError: 'NoneType' object is not callable

> # nothing
> print soup.findAll('param',{'name':'movie'})

Works for me:

In [16]: soup.findAll('param', {'name': 'movie'})
Out[16]:
[<param name="movie" value="url">
</param>]

> # nothing
> print soup.findAll('object')

This too:

In [17]: soup.findAll('object')
Out[17]:
[<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/
swflash.cab#version=7,0,19,0" width="640" height="400">
<param name="movie" value="url">
</param><param name="quality" value="high"></param><param name="SCALE" value="showall">
<embed src="url" quality="highpluginspage=http://www.macromedia.com/go/" getflashplayer="getflashplayer" type="application/x-shockwave-flash" width="640" height="400" bgcolor="#000000" scale="showall">
</embed>
</param></object>]

Ciao,
	Marc 'BlackJack' Rintsch



More information about the Python-list mailing list