DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Snippets has posted 5883 posts at DZone. View Full User Profile

Get Link Popularity On Delicious

04.06.2005
| 8197 views |
  • submit to reddit
        We are using python's delicious-py module

  
def get_popular_count(user="user"):
    import delicious
    notapi = delicious.DeliciousNOTAPI()

    #Get user's posts 
    user_posts = notapi.get_posts_by_user(user)

    data = '#tagID popularity\n' 
    
    #For each url, get how popular it is
    for i in range(len(user_posts)):
        data += str(i)+" "+str(len(notapi.get_posts_by_url(user_posts[i]["url"])))+'\n' 
    
    str1 = user + "-data" #file name
    data_file = file(str1,'w')
    data_file.write(data)
    data_file.close()

The resulting file will look like this:
$ less jemisa-data
#tagID popularity
0 6
1 744
2 928
3 120
4 1934
5 111
6 425
7 16
8 19
9 2
10 44
11 308
12 12
13 1
14 1
15 7
16 3
17 46
18 7
19 139
20 318
21 174
22 288
23 3
24 1
25 33
26 3
27 154