def print_me(self, print_summary=False, seen_as_new=False): title = self.entry.title link = self.entry.link try: summary = unescape(strip(self.entry.summary)) except AttributeError: summary = "" if 'published' in self.entry.keys(): published = self.entry.published.rsplit(' ', 1)[0] else: published = None if seen_as_new: str_new = " \x02new!\02 " else: str_new = " " if published is not None: print_console("%s%s%s - \x1f%s\x1f (%s)" % (self.feed.logo, str_new, title, link, published)) else: print_console("%s%s%s - %s" % (self.feed.logo, str_new, title, link)) if print_summary: for l in summary.split("\n"): l = l.strip() if len(l) > 0: print_console("%s %s" % (self.feed.logo, l))
def print_me(self, print_summary=False, seen_as_new=False): title = self.entry.title link = self.entry.link try: summary = unescape(strip(self.entry.summary)) except AttributeError: summary = "" if 'published' in self.entry.keys(): published = self.entry.published.rsplit(' ', 1)[0] else: published = None if seen_as_new: str_new = " \x02new!\02 " else: str_new = " " if published is not None: print_console("%s%s%s - %s (%s)" % (self.feed.logo, str_new, title, link, published)) else: print_console("%s%s%s - %s" % (self.feed.logo, str_new, title, link)) if print_summary: for l in summary.split("\n"): if len(l) > 0: print_console("%s %s" % (self.feed.logo, l))
def format(comment): comment = unescape(comment) comment = comment.replace('<br>', ' ') comment = comment.replace('<wbr>', '') # greentext open comment = comment.replace('<span class="quote">', '3') comment = comment.replace('<span class="deadlink">', '3') # close color comment = comment.replace('</span>', '') # remove the rest of html tags comment = strip(comment) return comment
print_console("Board %s: Not Found!" % b) else: print_console("Feed %s: Not Found" % logo) if f.bozo == 1: print_console("%s omg :( %s" % (f.bozo, f.bozo_exception)) exit(-1) try: entry = f.entries[n] except IndexError: print_console("Entry not available") exit(-1) title = entry.title link = entry.link summary = unescape(strip(entry.summary)) if 'published' in entry.keys(): published = entry.published.rsplit(' ', 1)[0] else: published = None if published is not None: print_console("%s %s - %s (%s)" % (logo, title, link, published)) else: print_console("%s %s - %s" % (logo, title, link)) for l in summary.split("\n"): if len(l) > 0: print_console("%s %s" % (logo, l))
print_console("Board %s: Not Found!" % b) else: print_console("Feed %s: Not Found" % logo) if f.bozo == 1: print_console("%s omg :( %s" % (f.bozo, f.bozo_exception)) exit(-1) try: entry = f.entries[n] except IndexError: print_console("Entry not available") exit(-1) title = entry.title link = entry.link summary = unescape(strip(entry.summary)) if "published" in entry.keys(): published = entry.published.rsplit(" ", 1)[0] else: published = None if published is not None: print_console("%s %s - %s (%s)" % (logo, title, link, published)) else: print_console("%s %s - %s" % (logo, title, link)) for l in summary.split("\n"): if len(l) > 0: print_console("%s %s" % (logo, l))
import urllib import sys import code import json as m_json from mylib import print_console, unescape, strip logo = "2G4o8o2g3l4e" if len(sys.argv) < 2: print_console("%s search syntax: !google <terms>"); exit(-1) query = " ".join(sys.argv[1:]) print_console("%s search: %s" % (logo, query)) query = urllib.urlencode ({ 'q' : query }) response = urllib.urlopen('http://ajax.googleapis.com/ajax/services/search/web?v=1.0&' + query).read() json = m_json.loads(response) results = json['responseData']['results'] n = 0 for result in results: title = strip(unescape(result['title'].replace("<b>","").replace("</b>", ""))) url = result['url'] # was URL in the original and that threw a name error exception print_console("%s: %s" % (title, url))
# ../mylib.py sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) from mylib import print_console, unescape, strip logo = "2G4o8o2g3l4e" if len(sys.argv) < 2: print_console("%s search syntax: !google <terms>" % logo); exit(-1) query = " ".join(sys.argv[1:]) string = "%s %s: " % (logo, query) query = urllib.urlencode ({ 'q' : query }) response = urllib.urlopen('http://ajax.googleapis.com/ajax/services/search/web?v=1.0&' + query).read() json = m_json.loads(response) results = json['responseData']['results'] i = 0 for result in results[:3]: i += 1 title = strip(unescape(result['title'].replace("<b>","").replace("</b>", ""))).encode("utf-8") url = urllib.unquote(result['url']).encode("utf-8") # was URL in the original and that threw a name error exception string = string + "%s (%s); " % (title, url) if i > 0: print_console("%s: %s" % (string, url)) else: print_console("No results!")