User:Lidia.Pereira/PNM/Fluffying

From XPUB & Lens-Based wiki

<--! Replacing "fucking" with "baking" on the comments for the Top Rated YouTube videos.

import urllib2
import json
import random

feed = urllib2.urlopen("http://gdata.youtube.com/feeds/api/standardfeeds/top_rated?v=2&alt=jsonc")

data = json.load(feed)

topRated = data['data'] ['items']

for i in topRated:
    print i['id']
    url = "http://gdata.youtube.com/feeds/api/videos/"+i['id']+"/comments?alt=json"
    feed2 = urllib2.urlopen(url) #it stores the generated url into this new feed variable
    data2 = json.load(feed2)
    for c in data2 ['feed']['entry']: 
        content = c['content']['$t']
        print content.replace("fucking","baking")

-->