The thoughts of a web 2.0 research fellow on all things in the technological sphere that capture his interest.

Saturday 29 March 2008

Python & the Flickr API on the Eee PC

Until yesterday I hadn't really thought about programming on the Eee PC, but once I started looking I was surprised how easy it was: Unbeknown to me, it has had Python 2.4 and 2.5 sitting there the whole time! Despite not being a particularly competent programmer, I found Python to be very user friendly, and look forward to programming on the Eee PC in a variety of settings in the future. My first Python program was used to find random Flickr users:

> import flickrapi
> import random
> api_key = 'XXXXXXXXXXXXXXX'
> for counter in range (1,1000):
>>> flickr = flickrapi.FlickrAPI(api_key, fail_on_error=False)
>>> a=random.randint(1, 99999999)
>>> b=random.randint(0,1)
>>> c=random.randint(0,9)
>>> d=str(a)+"@N"+str(b)+str(c)
>>> photos = flickr.photos_search(user_id=d)
>>> if photos['stat'] == "ok":
>>>>>> print d
> print 'done'

Webometric studies are always searching for ways of finding random users, unfortunately I have no idea how Flickr assigns its user_ids. O'Reilly's "Flickr Hacks' says:

"...a string of numbers, followed by an at sign (@), an N, and two more numbers (often 00 or 01)..."

Not exactly specific. The program calculates a number up to eight digits long before the '@N' and from 00 to 19 after the '@N'. Whilst most may be 00 or 01, I found them as high as 08. If anyone knows of any user_ids not included in these parameters, please let me know.

Sending 1,000 queries, 10 random users were identified. Not exactly efficient.

Labels: , , , ,

posted by David at

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home