User:Lidia.Pereira/PNM/Fluffying: Difference between revisions

From XPUB & Lens-Based wiki
(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...")
 
No edit summary
Line 1: Line 1:
Replacing "fucking" with "baking" on the comments for the Top Rated YouTube videos.
<--! Replacing "fucking" with "baking" on the comments for the Top Rated YouTube videos.


<syntaxhighlight lang="python">
<syntaxhighlight lang="python">
Line 21: Line 21:
         print content.replace("fucking","baking")
         print content.replace("fucking","baking")
</syntaxhighlight>
</syntaxhighlight>
-->

Revision as of 15:07, 26 September 2013

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

-->