User:Lidia.Pereira/PNM/Fluffying

From XPUB & Lens-Based wiki
< User:Lidia.Pereira‎ | PNM
Revision as of 14:33, 26 September 2013 by Lidia.Pereira (talk | contribs) (Created page with "Replacing "fucking" with "baking" on the comments for the Top Rated YouTube videos. <syntaxhighlight lang="python"> import urllib2 import json import random feed = urllib2.u...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

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")