Skip to content

Instantly share code, notes, and snippets.

@tbeseda
Created March 8, 2012 16:22
Show Gist options
  • Save tbeseda/2001894 to your computer and use it in GitHub Desktop.
Save tbeseda/2001894 to your computer and use it in GitHub Desktop.
Scrape Flickr User's Photos to a Concise JSON Object
flickr = require './flickr'
photos = flickr.results.photos.photo
# Example input object
###
id: 6711220011
owner: 43769855@N02
secret: fa596d04c5
server: 7162
farm: 8
title: 109
ispublic: 1
isfriend: 0
isfamily": 0
###
# Example target object
###
id: "5681612321"
image: "http://farm6.static.flickr.com/5188/5681612321_681b61281e_z.jpg"
thumbnail: "http://farm6.static.flickr.com/5188/5681612321_681b61281e_s.jpg"
###
new_photos = []
console.log 'mapping', photos.length, 'original photos'
for p in photos
new_photos.push
id: p.id
image: "http://farm#{p.farm}.staticflickr.com/#{p.server}/#{p.id}_#{p.secret}_z.jpg"
thumbnail: "http://farm#{p.farm}.staticflickr.com/#{p.server}/#{p.id}_#{p.secret}_s.jpg"
console.log 'done.\n', JSON.stringify new_photos
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment