Ejemplo n.º 1
0
def getHeadlines():
    """Gets headlines from The Technician (technicianonline.com)"""
    #    url = "http://www.technicianonline.com/se/1.312893-1.312893"
    url = "http://feeds.arstechnica.com/arstechnica/news?format=xml"
    rss = ET.parse(urllib.urlopen(url)).getroot()
    articles = rss.findall("channel/item")[:3]

    headlines = []
    for i in xrange(0, 3):
        headlines.append(
            "{0}:\n\t{1}... \n\t{2}".format(
                articles[i].find("title").text,
                articles[i].find("description").text,
                tiny.tiny_url(articles[i].find("link").text)[7:],
            )
        )

    return headlines
Ejemplo n.º 2
0
def checkWoot(event, force=True):
    '''Checks woot.com for the latest deal. force says whether to report the deal if it hasn't changed since the last check.'''
    global latestTitle
    global latestPrice
    global soldout
    try:
        rss = ET.parse(urllib.urlopen(url)).getroot()  # Get the woot RSS feed and prepare to parse it
    except:
        return
    title = rss.findall("channel/item/title")[0].text
    price = rss.findall("channel/item/{http://www.woot.com/}price")[0].text
    soldout = rss.findall("channel/item/{http://www.woot.com/}soldoutpercentage")[0].text
    soldout = 100 - (float(soldout) * 100)  # In the feed item, soldout is a decimal percent
    buylink = rss.findall("channel/item/{http://www.woot.com/}purchaseurl")[0].text
    buylink = tiny.tiny_url(url=buylink)

    if latestTitle == title and force != True:  # Don't report the deal if it hasn't changed since last time
        return
    latestTitle = title
    latestPrice = price
    event.reply("Woot! - %s --- %s --- %s%% left! --- Purchase: %s" % (unicode(latestTitle), unicode(latestPrice), unicode(soldout), buylink))