All pastes #34525 Raw Edit

Jay jmailone@gmail

public python v1 · immutable
#34525 ·published 2005-12-21 21:15 UTC
rendered paste body
# Creates a RSS Newspaper from digg only!# This program will not work unless you have Amara installedimport htmllibimport httplibimport urllibimport ftplibimport osimport amaraimport HTMLgen as htm#Change the DIRos.chdir("C:\Python24\#rssdigg")def line():    print "__________________________________________________"def line2():    print "=================================================="class Digg:    pass    print "Digg Imported"        # Amara importing     rssDigg = amara.parse("http://www.digg.com/rss/index.xml")    # Get the title and description    # First TOPIC     d1_title = rssDigg.rss.channel.item[0].title    d1_data = rssDigg.rss.channel.item[0].description    # Second TOPIC    d2_title = rssDigg.rss.channel.item[1].title    d2_data = rssDigg.rss.channel.item[1].description    # Third Topic    d3_title = rssDigg.rss.channel.item[2].title    d3_data = rssDigg.rss.channel.item[2].description    # Fourth Topic    d4_title = rssDigg.rss.channel.item[3].title    d4_data = rssDigg.rss.channel.item[3].description    # Firth Topic    d5_title = rssDigg.rss.channel.item[4].title    d5_data = rssDigg.rss.channel.item[4].description       # Convert the nodes to string values    # First Node    d1 = str(d1_title)    d11 = str(d1_data)    # Second Node    d2 = str(d2_title)    d22 = str(d2_data)    # Third Node    d3 = str(d3_title)    d33 = str(d3_data)    # Forth Node    d4 = str(d4_title)    d44 = str(d4_data)    # Fifth Node    d5 = str(d5_title)    d55 = str(d5_data)    def printDigg(self):         # Write all the titles and descriptions to a file.        woo = open("Digg_Feed.txt", "w")           woo.write("TOP FIVE TOPICS FOR DIGG ARE:   " "\n")        woo.write("                                " "\n")        woo.write("================================" "\n")        woo.write(Digg.d1)        woo.write("\n")        woo.write("___________+"                     "\n")        woo.write(Digg.d11 + "\n")        woo.write("\n")        woo.write("\n")        woo.write("++++++++++++++++++++++++++++++++" "\n")        woo.write(Digg.d2)        woo.write("\n")        woo.write("___________+"                     "\n")        woo.write(Digg.d22)        woo.write("\n")        woo.write("\n")        woo.write("+++++++++++++++++++++++++++++++ " "\n")        woo.write(Digg.d3)        woo.write("\n")        woo.write("___________+"                     "\n")        woo.write(Digg.d33)        woo.write("\n")        woo.write("\n")        woo.write("+++++++++++++++++++++++++++++++ " "\n")        woo.write(Digg.d4)        woo.write("\n")        woo.write("___________+"                     "\n")        woo.write(Digg.d44)        woo.write("\n")        woo.write("\n")        woo.write("+++++++++++++++++++++++++++++++ " "\n")        woo.write(Digg.d5)        woo.write("\n")        woo.write("___________+"                     "\n")        woo.write(Digg.d55)        woo.write("\n")        woo.write("\n")        woo.write("+++++++++++++++++++++++++++++++ " "\n")        # Close the file        woo.close        # Make file readable        woo = open("Digg_Feed.txt", "r")        print "Go to your text file called, 'Digg_Feed.txt'. Your text is in there"                        def printDigg():    D = Digg()    Digg.printD = D.printDigg    Digg.printD()    class  Weather:    pass    print "Weather is imported"    rssw = amara.parse("http://www.rssweather.com/wx/us/ga/roswell/rss.php?config=&forecast=zandh&place=roswell&state=ga&zipcode=&country=us&county=13121&zone=gaz033&alt=rss20a")    rwTitle = rssw.rss.channel.title    rw1Cat = rssw.rss.channel.item[0].category    rw1Title = rssw.rss.channel.item[0].title    rw1Date = rssw.rss.channel.item[0].pubDate    rw1Temp = rssw.rss.channel.item[0].description            rssw = amara.parse("http://www.rssweather.com/wx/us/ga/roswell/rss.php?config=&forecast=zandh&place=roswell&state=ga&zipcode=&country=us&county=13121&zone=gaz033&alt=rss20a")    rw1Cat = rssw.rss.channel.item[1].category    rw2Title = rssw.rss.channel.item[1].title    rw2Descrp = rssw.rss.channel.item[1].description        rwstr1title = str(rw1Title)    def printCurrent(self):                print Weather.rwTitle        line2()        print "Date:", Weather.rw1Date        print "Category:", Weather.rw1Cat        print "Title ::  ",  Weather.rw1Title        line()        print "Description:", Weather.rw1Temp    def print2Night(self):        print Weather.rwTitle        line2()        print "Date:", Weather.rw2Date        print "Category:", Weather.rw2Cat        print "Title ::  ",  Weather.rw2Title        line()        print "Description:", Weather.rw2Temp        def weatherCurrent():    W = Weather()    Weather.printC = W.printCurrent    Weather.printC()def weather2Night():    W = Weather()    Weather.printT = W.print2Night    Weather.printT()class Wired:    passclass SlashDot:    passdef printALL():    # Convert to HTML    # Digg (works just fine)    S = htm.Strong()    d = htm.Table("RSSNewspaper")    h = ["The Top 5 Stories on Digg are:", "Weather"]    d.heading = h    Sd1 = str(Digg.d1)    Sd2 = str(Digg.d2)    Sd3 = str(Digg.d3)    Sd4 = str(Digg.d4)    Sd5 = str(Digg.d5)    FirstT = [S(Sd1)]    FirstD = [Digg.d11]    SecondT = [S(Sd2)]    SecondD = [Digg.d22]    ThirdT = [S(Sd3)]    ThirdD = [Digg.d33]    ForthT = [S(Sd4)]    ForthD = [Digg.d44]    FifthT = [S(Sd5)]    FifthD = [Digg.d55]        # Weather... (finish it , (fine))    curwstr = str("Current Weather: ")    currentWE = [S(curwstr)]            westrTitle = str(Weather.rw1Title)    westr2date = str(Weather.rw1Date)    westr2cat = str(Weather.rw1Cat)    westr2temp = str(Weather.rw1Temp)        WeatherW2title = [S("Title:       ") + "\n" + "\t" + westrTitle]    WeatherW2date = [S("Date:         ") + "\n" + "\t" + westr2date]    WeatherW2cat = [S("Catergory:     ") + "\n" + "\t" + westr2cat]    WeatherW2temp = [S("Temperature:  ") + "\n" + "\t" + westr2temp]        Empty = str(" ")    EmptyC = [Empty]        Row1 = FirstT + currentWE    Row2 = FirstD + EmptyC    Row3 = SecondT + WeatherW2title    Row4 = SecondD + WeatherW2date    Row5 = ThirdT + WeatherW2cat    Row6 = ThirdD + WeatherW2temp    Row7 = ForthT + EmptyC    Row8 = ForthD + EmptyC    Row9 = FifthT + EmptyC    Row10 = FifthD + EmptyC                    d.body = [Row1, Row2, Row3, Row4, Row5, Row6, Row7, Row8, Row9, Row10]        k = str(d)    woo2html = open("woo2html.htm", "w")    woo2html.write(k)    woo2html.close    woo2html = open("woo2html.htm", "r")printALL()# tkinter #######################################################print "++++++++++++++++++++++++++++++++++++++++"print "This is just telling you that the program is done"