python - parsing rss different tags extract image -


hi trying extract images multiple sites rss.

first rss

<enclosure type="image/jpeg" length="321742" url="http://www.sitio.com.uy//uploads/2014/10/19/54441d68e01af.jpg"/> 

second rss

<g:image_link>http://img.sitio2.com/imagenes/314165_20150422201743_635653477836873822w.jpg</g:image_link> 

need extract url of image.

my code beatifulsoup in python

    response = requests.get(url)     soup = bs4.beautifulsoup(response.text)      items = soup.find_all('item')      item in items:         title = item.find('title').get_text().encode('utf-8')         description = item.find('description').get_text().encode('utf-8')         category = item.find('category').get_text().encode('utf-8')         image = item.find('enclosure')          print(image) 

you can search multiple tags using tag list.

item.find(['enclosure', 'g:image_link']) 

this return first tag finds. if there multiple tags use find_all.

item.find_all(['enclosure', 'g:image_link']) 

Popular posts from this blog

c# - ODP.NET Oracle.ManagedDataAccess causes ORA-12537 network session end of file -

matlab - Compression and Decompression of ECG Signal using HUFFMAN ALGORITHM -

utf 8 - split utf-8 string into bytes in python -