コード例 #1
0
ファイル: gag.py プロジェクト: ajdiaz/whistler
    def cmd_gag(self, msg, args):
        """!gag   - return a random image from 9gag."""

        try:
            data = htmlparse("http://9gag.com/random", ".badge-item-animated-img")
            title = data.attr("alt")
            img = data.attr("src")
        except:
            data = htmlparse("http://9gag.com/random", ".badge-item-img")
            title = data.attr("alt")
            img = data.attr("src")
            # We need to duplicate data access here cuz of the object is not really parsed until
            # attr is invoked.

        self.send(msg['from'], img, msg['type'])

        return str(title)
コード例 #2
0
ファイル: gag.py プロジェクト: socialloser1/whistler
    def cmd_gag(self, msg, args):
        """!gag   - return a random image from 9gag."""

        try:
            data = htmlparse("http://9gag.com/random",
                             ".badge-item-animated-img")
            title = data.attr("alt")
            img = data.attr("src")
        except:
            data = htmlparse("http://9gag.com/random", ".badge-item-img")
            title = data.attr("alt")
            img = data.attr("src")
            # We need to duplicate data access here cuz of the object is not really parsed until
            # attr is invoked.

        self.send(msg['from'], img, msg['type'])

        return str(title)
コード例 #3
0
ファイル: devopsme.py プロジェクト: ajdiaz/whistler
    def cmd_devopsme(self, msg, args):
        """!devopsme   - return a random image from devopsreactions."""

        data = htmlparse("http://devopsreactions.tumblr.com/random", ".item_content")

        title = data.find(".post_title").find("a").text()
        img = data.find("p").find("img").attr("src")

        self.send(msg['from'], img, msg['type'])

        return str(title)
コード例 #4
0
    def cmd_devopsme(self, msg, args):
        """!devopsme   - return a random image from devopsreactions."""

        data = htmlparse("http://devopsreactions.tumblr.com/random",
                         ".item_content")

        title = data.find(".post_title").find("a").text()
        img = data.find("p").find("img").attr("src")

        self.send(msg['from'], img, msg['type'])

        return str(title)