Webometric Thoughts

August 31, 2008

Twittering with Python …on the web

Filed under: Python,Twitter,programming — admin @ 9:20 pm

Programming is really addictive, especially when you are bad at it. Whilst the proficient programmer can deal with their problems in a matter of minutes, bad programmers can spend hours on the simplest of problems. Today I decided to start messing about with some server-side programming for the first time; now I find myself wondering what happened to my Sunday.

This particular form allows anyone to post to your Twitter account (and then displays the comments that have already been posted):

Enter Comment:

Now all I need to do is think of a use for anonymous twittering….
(http://twitter.com/blogcomments)

The code:
>#!/usr/bin/python
>import cgi
>import urllib
>print “Content-type: text/html\n\n”
>form=cgi.FieldStorage()
>data = urllib.urlencode({“status” : form["status"].value})
>res = urllib.urlopen(“http://USERNAME:PASSWORD@twitter.com/statuses/update.xml”
, data)
>lines = urllib.urlopen(‘http://twitter.com/statuses/user_timeline/16066835.rss’)
.readlines()
>for line in lines:
>>>if line.find(‘title’) <>-1:
>>>>>>line=line[11:(len(line)-9)]
>>>>>>print line

July 14, 2008

Is the phone the future of programming?

Filed under: N95,Python,mobile illiteracy — admin @ 8:16 am

Way back in April I wrote that the answer to Bill Thompson’s “Who will write tomorrow’s code?” may be found amongst the Eee PC generation of users. However, after having my programming interest piqued once again by last week’s Python workshop, I discovered I had regularly been carrying another device around that could have Python easily installed: my N95.

Whereas the Eee PC takes programming out of the bedroom into the community, programming on the mobile phone takes portability and sharing to a whole new level. Even more importantly, mobile phone programming would instantly grab the attention of the younger generation. Mobile phones are filled with their music, their videos, and their friends. Enabling users to create applications that use the data they already have (and more that they can download) can’t help but be popular.

Python is easy to install directly onto the mobile phone (nb. you need to install the PythonScriptShell as well as PythonForS60), and by installing simple text software (such as Light Notepad) you can program directly on the mobile (albeit rather clunkily) rather than having to send it across from a PC.

Whilst Python for the S60 has now been available for a couple of years, you get the distinct impression that it is only really popular amongst those people who would be programming anyway. Surely its time that it went mainstream and introduced more people to programming. The solution to the perceived programmer shortage would seem to be in people’s pockets.

July 10, 2008

Python for API Dummies

Filed under: API,Flickr,Python,Yahoo,workshop — admin @ 6:08 pm

Python is a really simple programming language for the novice programmer. As such I held an afternoon’s “workshop” for a couple of PhD students in my front room:

The aim of the workshop was to provide sufficient information about programming in Python so that at the end of the afternoon the user could:
-Install Python libraries
-Download information through various APIs
-Manipulate the downloaded information.
As it was necessary to create an extensive slide show, covering everything from installing Python to getting data from the Yahoo API, I thought it may potentially be of interest to other novice users who don’t know where to start.



It doesn’t necessarily include the quickest or most efficient way of doing things, but it is simple and does the job.

If you have any questions about specific points, feel free to ask…the questions can’t be more stupid than the questions the PhD students asked…and some of the slides could probably benefit from further explanation.

April 6, 2008

Average photos per Flickr Member: ZERO

Filed under: API,Flickr,Python — admin @ 1:40 pm

67% of Flickr members have no photos! Whilst Lotka’s law teaches us that the majority of contributors to a community make very few contributions, I was still surprised at the number of members with no photos; after all, I am not talking visitors to the site, but those who have taken the trouble to join. What is the point of joining Flickr if you are not going to put photos on the site?

Data was collected about the number of photos for 324 randomly selected users. 216 had no photos, an additional 58 had less than 20, with only 50 having over 20:


Really I should have a look at whether these missing users are active in other ways, (e.g., members of groups, leavers of comments), but this was little more than an aside as I spend my time messing about with Python. I have now loaded Python on my main computer as well as my Eee PC, and can barely believe how easy it is!

April 2, 2008

Programming Python on the Eee PC

Filed under: API,Eee PC,Python,RM minibook,programming — admin @ 8:30 am

Since Friday I have been spending a lot of time programming in Python on the Eee PC, the more I program the more I like both the language and the ease if having it on the Eee PC. Over at the Beeb Bill Thompson poses the question “Who will write tomorrow’s code?”, I suggested last week that the Eee PC (and other similar devices) may be the answer, and now I more convinced that ever.

Already I have been writing codes in python that use the Twitter, Flickr and Digg API, programs that can form the basis of numerous articles that I will never get around to writing…it’s SO easy (with the possible exception of installing the simplejson library that the Twitter library relies on). Just wish some other sites would roll out APIs (e.g., Stumbleupon and Reddit).

So, do we all need to become top-class programmers? No. But if you can program, even to a basic level, the web becomes a lot more exciting and interactive place.

March 29, 2008

Python & the Flickr API on the Eee PC

Filed under: Eee PC,Flickr,Python,RM minibook,program — admin @ 10:05 pm

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.

Powered by WordPress