# -*-coding: utf-8 -*- import feedparser import html2text import FB d = feedparser.parse("http://www.tmd.go.th/xml/region_daily_forecast.php?RegionID=7") # print d['feed']['title'] # print d['feed']['link'] title = d["feed"]["title"] link = d["feed"]["link"] # print "------------------" txt = d.entries[0]["summary_detail"]["value"] # print txt # print "------------------" plain_txt = html2text.html2text(txt) i = plain_txt.find("![]") j = plain_txt.find(")", i) img_link = plain_txt[i + 4 : j] s = plain_txt[i : j + 1] # print "image link:'",img_link,"'" plain_txt = title + "\n" + plain_txt.replace(s, "") + "\n" + link print plain_txt.encode("utf-8") FB.post_wall(plain_txt.encode("utf-8"))
print "Old date:",data if (date1 == data): result = False else: file.seek(0,0) file.write(str(date1)) result = True file.close() return result d=feedparser.parse('http://feeds.feedburner.com/Setorth-form45') updated = d['feed']['updated'] link = d['feed']['links'][0]['href'] #print d['feed'] #print "Link:",link txt = "" if (isNewDate(updated)): print "New update:", updated for i in d.entries: txt = txt + i['title'] +"\n" txt = txt.rstrip() txt = link+"\n"+ txt #print "Txt:",txt if (txt.find("http") <=5): print "No update" else: FB.post_wall(txt.encode("utf-8")) else: print "No update since:",updated