Posted By

alces on 03/04/13


Tagged

rss regexp XmlParser findAll


Versions (?)

Save all images from RSS feed


 / Published in: Groovy
 

URL: rss_sav_img

Gets "src" attributes from all "img" tags in RSS entries descriptions

  1. RSS_URL = 'http://35photo.ru/rss/photo_day.xml'
  2. OUT_NAM = "/var/tmp/${new Date().format('YYYYMMddHHmmss')}"
  3.  
  4. new XmlParser().parse(RSS_URL).channel.item.description*.text()*.findAll(/(?i)<img\s[^>]+>/) {im ->
  5. im.findAll(/(?i)src=['"]([^'"]+\.([^.'"]+))['"]/) {ma, sr, ex ->
  6. new FileOutputStream(OUT_NAM + "${sr.hashCode()}.$ex").write(new URL(sr).getBytes())
  7. }
  8. }

Report this snippet  

You need to login to post a comment.