Example #1
0
def user_submitted():
    username = request.args.get('id')
    api = API.using_request(request)
    api_response = api.user(username, 'submitted')

    rss_title = 'Hacker News: %s submitted RSS feed' % username
    rss_link = 'https://news.ycombinator.com/submitted?id=%s' % username
    rss = RSS(api_response, rss_title, rss_link)
    return rss.response()
Example #2
0
def new_comments():
    query = request.args.get('q')
    api = API.using_request(request)
    if query:
        rss_title = 'Hacker News: "%s" comments' % query
    else:
        rss_title = 'Hacker News: New Comments'
    rss = RSS(api.comments(), rss_title, 'https://news.ycombinator.com/newcomments')
    return rss.response()
Example #3
0
def newest():
    query = request.args.get('q')
    api = API.using_request(request)
    if query:
        rss_title = 'Hacker News: "%s"' % query
    else:
        rss_title = 'Hacker News: Newest'
    rss = RSS(api.newest(), rss_title, 'https://news.ycombinator.com/newest')
    return rss.response()
Example #4
0
def user_threads():
    username = request.args.get('id')
    api = API.using_request(request)
    api_response = api.user(username, 'threads')

    rss_title = 'Hacker News: %s threads RSS feed' % username
    rss_link = 'https://news.ycombinator.com/threads?id=%s' % username
    rss = RSS(api_response, rss_title, rss_link)
    return rss.response()
Example #5
0
def who_is_hiring(include=None):
    api = API.using_request(request)
    if include is None:
        rss = RSS(api.who_is_hiring('all'), 'whoishiring', 'https://news.ycombinator.com/submitted?id=whoishiring')
    elif include == 'jobs':
        rss = RSS(api.who_is_hiring(include), 'whoishiring - Who is hiring?', 'https://news.ycombinator.com/submitted?id=whoishiring')
    elif include == 'hired':
        rss = RSS(api.who_is_hiring(include), 'whoishiring - Who wants to be hired?', 'https://news.ycombinator.com/submitted?id=whoishiring')
    elif include == 'freelance':
        rss = RSS(api.who_is_hiring(include), 'whoishiring - Freelancer? Seeking freelancer?', 'https://news.ycombinator.com/submitted?id=whoishiring')
    return rss.response()
Example #6
0
def new_comments():
    query = request.args.get('q')
    api = API.using_request(request)
    if query:
        del api.params['restrictSearchableAttributes']
        rss_title = 'Hacker News: "%s" comments' % query
    else:
        rss_title = 'Hacker News: New Comments'
    rss = RSS(api.comments(), rss_title,
              'https://news.ycombinator.com/newcomments')
    return rss.response()
Example #7
0
    def print_rss(self):
        rss = RSS(encode = "UTF-8",
                  title = self.message["logo"],
                  parent = "http://" + self.host,
                  uri = "http://" + self.host
                                  + self.gateway_cgi + self.sep + "rss",
                  description = self.message["description"],
                  xsl = config.xsl)
        cachelist = CacheList()
        now = int(time())
        for cache in cachelist:
            if cache.valid_stamp + config.rss_range >= now:
                title = self.escape(self.file_decode(cache.datfile))
                path = self.appli[cache.type]+self.sep+self.str_encode(title)
                for r in cache:
                    if r.stamp + config.rss_range < now:
                        continue
                    r.load_body()
                    desc = self.rss_text_format(r.get("body", ""))
                    content = self.rss_html_format(r.get("body", ""),
                                                   self.appli[cache.type],
                                                   title)
                    attach = r.get('attach', '')
                    if attach:
                        suffix = r.get('suffix', '')
                        if not re.search(r'^[0-9A-Za-z]+$', suffix):
                            suffix = txt
                        content += '\n    <p>' + \
                            '<a href="http://%s%s%s%s/%s/%d.%s">%d.%s</a></p>'\
                            % (self.host, self.appli[cache.type], self.sep,
                               cache.datfile,
                               r.id, r.stamp, suffix,
                               r.stamp, suffix)
                    if cache.type == "thread":
                        permapath = "%s/%s" % (path[1:], r.id[:8])
                    else:
                        permapath = path[1:]
                    rss.append(
                        permapath,
                        date = r.stamp,
                        title = title,
                        creator = self.rss_text_format(r.get('name', '')),
                        subject = [str(i) for i in cache.tags],
                        description = desc,
                        content = content)
                    r.free()

        self.stdout.write("Content-Type: text/xml; charset=UTF-8\n")
        try:
            self.stdout.write("Last-Modified: %s\n" %
                              self.rfc822_time(rss[rss.keys()[0]].date))
        except IndexError, KeyError:
            pass
Example #8
0
    def print_rss(self):
        rss = RSS(encode="UTF-8",
                  title=self.message["logo"],
                  parent="http://" + self.host,
                  uri="http://" + self.host + self.gateway_cgi + self.sep +
                  "rss",
                  description=self.message["description"],
                  xsl=config.xsl)
        cachelist = CacheList()
        now = int(time())
        for cache in cachelist:
            if cache.valid_stamp + config.rss_range >= now:
                title = self.escape(self.file_decode(cache.datfile))
                path = self.appli[cache.type] + self.sep + self.str_encode(
                    title)
                for r in cache:
                    if r.stamp + config.rss_range < now:
                        continue
                    r.load_body()
                    desc = self.rss_text_format(r.get("body", ""))
                    content = self.rss_html_format(r.get("body", ""),
                                                   self.appli[cache.type],
                                                   title)
                    attach = r.get('attach', '')
                    if attach:
                        suffix = r.get('suffix', '')
                        if not re.search(r'^[0-9A-Za-z]+$', suffix):
                            suffix = txt
                        content += '\n    <p>' + \
                            '<a href="http://%s%s%s%s/%s/%d.%s">%d.%s</a></p>'\
                            % (self.host, self.appli[cache.type], self.sep,
                               cache.datfile,
                               r.id, r.stamp, suffix,
                               r.stamp, suffix)
                    if cache.type == "thread":
                        permapath = "%s/%s" % (path[1:], r.id[:8])
                    else:
                        permapath = path[1:]
                    rss.append(permapath,
                               date=r.stamp,
                               title=title,
                               creator=r.get('name', ''),
                               subject=[str(i) for i in cache.tags],
                               description=desc,
                               content=content)
                    r.free()

        self.stdout.write("Content-Type: text/xml; charset=UTF-8\n")
        try:
            self.stdout.write("Last-Modified: %s\n" %
                              self.rfc822_time(rss[rss.keys()[0]].date))
        except IndexError, KeyError:
            pass
Example #9
0
def story_comments():
    story_id = request.args.get('id')
    api = API.using_request(request)
    api_response = api.comments(story_id=story_id)

    if api_response['hits']:
        story = api_response['hits'][0]
        rss_title = 'Hacker News: New Comments on "%s"' % story['story_title']
    else:
        rss_title = 'Hacker News: New Comments'

    rss_link = 'https://news.ycombinator.com/item?id=%s' % story_id
    rss = RSS(api_response, rss_title, rss_link)
    return rss.response()
Example #10
0
def story_comments():
    story_id = request.args.get('id')
    api = API.using_request(request)
    api_response = api.comments(story_id=story_id)

    if api_response['hits']:
        story = api_response['hits'][0]
        rss_title = 'Hacker News: New Comments on "%s"' % story['story_title']
    else:
        rss_title = 'Hacker News: New Comments'

    rss_link = 'https://news.ycombinator.com/item?id=%s' % story_id
    rss = RSS(api_response, rss_title, rss_link)
    return rss.response()
Example #11
0
    def go(self, url=None):
        if url is None: url = self.varURL.get()

        contentWindow = tkinter.Toplevel()
        textContainer = tkinter.Text(contentWindow, wrap='word', height=25, width=100)
        contentClose = tkinter.Button(contentWindow, text='Close', command=contentWindow.destroy)

        textContainer.tag_add('default', '0.0')
        textContainer.tag_config('default', font=self.defaultFont)
        textContainer.tag_config('hyper', foreground='blue', underline=1, font=self.defaultFont)

        contentWindow.title('RSS Feed')
        contentWindow.grid()
        textContainer.grid(row=0, column=0, columnspan=2, padx=10, pady=10)
        contentClose.grid(row=1, column=1, pady=5)

        # scrollbar for textContainer - must have same grid options as parent
        textScroll = tkinter.Scrollbar(contentWindow)
        textScroll.grid(row=0, column=0, columnspan=2, sticky='nse')
        textScroll.config(command=textContainer.yview)
        textContainer.config(yscrollcommand=textScroll.set)

        hyperlink = hyperlinkManager(textContainer)

        try:
            feedString = ''
            feed = RSS(url)
            contentWindow.title(feed.feedTitle)
            separator = '--------------------\n'
            for r in feed.records():
                textContainer.insert(tkinter.INSERT, separator, 'default')
                if ['title'] and r['link']:
                    textContainer.insert(tkinter.INSERT, r['title'] + '\n', hyperlink.add(r['link']))
                else:
                    if r['title']: textContainer.insert(tkinter.INSERT, r['title'] + '\n', 'default')
                    if r['link']: textContainer.insert(tkinter.INSERT, r['title'] + '\n', hyperlink.add(r['link']))
                if r['description']: textContainer.insert(tkinter.INSERT, r['description'] + '\n', 'default')

        except urllib.error.HTTPError as e:
            self.errorBox(e, contentWindow.destroy)
        except urllib.error.URLError as e:
            self.errorBox(e, contentWindow.destroy)
        except ValueError as e:
            if url:
                self.errorBox(e, contentWindow.destroy)
            else:
                contentWindow.destroy()
        except xml.parsers.expat.ExpatError as e:
            self.errorBox(e, contentWindow.destroy)
Example #12
0
    def addFeed(self):
        url = self.varURL.get()
        try:
            feed = RSS(url)
            rec = {
                'title': feed.feedTitle.strip(),
                'url': url.strip(),
                'description': feed.feedDescription.strip()
            }
            try:
                self._db.insert(rec)
            except sqlite3.IntegrityError:  # duplicate key - update instead
                self._db.update(rec)
                self.messageBox('Udpated in list: {}.'.format(rec['title']))
            else:
                self.fillListBox()
                self.messageBox('Added to list: {}.'.format(rec['title']))
        except urllib.error.HTTPError as e:
            self.errorBox(e)
        except urllib.error.URLError as e:
            self.errorBox(e)
        except ValueError as e:
            self.errorBox(e)
        except xml.parsers.expat.ExpatError as e:
            self.errorBox(e)

        self.varURL.set('')  # clear the URL box
Example #13
0
def main():
    urls = [
        'http://rss.cnn.com/rss/cnn_topstories.rss',
        'http://rss.cnn.com/rss/cnn_world.rss',
        'http://rss.cnn.com/rss/cnn_us.rss',
        'http://rss.cnn.com/rss/money_latest.rss',
        'http://rss.cnn.com/rss/cnn_allpolitics.rss',
        'http://rss.cnn.com/rss/cnn_tech.rss',
        'http://rss.cnn.com/rss/cnn_health.rss',
        'http://rss.cnn.com/rss/cnn_showbiz.rss',
        'http://rss.cnn.com/rss/cnn_travel.rss',
        'http://rss.cnn.com/rss/cnn_living.rss',
        'http://rss.cnn.com/rss/cnn_freevideo.rss',
        'http://feeds.reuters.com/news/artsculture',
        'http://feeds.reuters.com/reuters/businessNews',
        'http://feeds.reuters.com/reuters/companyNews',
        'http://feeds.reuters.com/reuters/entertainment',
        'http://feeds.reuters.com/reuters/environment',
        'http://feeds.reuters.com/reuters/healthNews',
        'http://feeds.reuters.com/reuters/lifestyle',
        'http://feeds.reuters.com/news/wealth',
        'http://feeds.reuters.com/reuters/MostRead',
        'http://feeds.reuters.com/reuters/oddlyEnoughNews',
        'http://feeds.reuters.com/reuters/peopleNews',
        'http://feeds.reuters.com/Reuters/PoliticsNews',
        'http://feeds.reuters.com/reuters/scienceNews',
        'http://feeds.reuters.com/reuters/sportsNews',
        'http://feeds.reuters.com/reuters/technologyNews',
        'http://feeds.reuters.com/reuters/topNews',
        'http://feeds.reuters.com/Reuters/domesticNews',
        'http://feeds.reuters.com/Reuters/worldNews',
        'http://feeds.bbci.co.uk/news/world/africa/rss.xml',
        'http://feeds.bbci.co.uk/news/world/asia/rss.xml',
        'http://feeds.bbci.co.uk/news/world/europe/rss.xml',
        'http://feeds.bbci.co.uk/news/world/latin_america/rss.xml',
        'http://feeds.bbci.co.uk/news/world/us_and_canada/rss.xml',
        'http://feeds.bbci.co.uk/news/england/rss.xml',
        'http://feeds.bbci.co.uk/news/northern_ireland/rss.xml',
        'http://feeds.bbci.co.uk/news/scotland/rss.xml',
        'http://feeds.bbci.co.uk/news/wales/rss.xmlhttp://feeds.bbci.co.uk/news/wales/rss.xml',
    ]
    dsn = "host='localhost' dbname='hacknet_db' user='******' password='******'"
    rss = RSS(urls, dsn)
    rss.parse()
Example #14
0
def who_is_hiring(include=None):
    api = API.using_request(request)
    if include is None:
        rss = RSS(api.who_is_hiring('all'), 'whoishiring',
                  'https://news.ycombinator.com/submitted?id=whoishiring')
    elif include == 'jobs':
        rss = RSS(api.who_is_hiring(include), 'whoishiring - Who is hiring?',
                  'https://news.ycombinator.com/submitted?id=whoishiring')
    elif include == 'hired':
        rss = RSS(api.who_is_hiring(include),
                  'whoishiring - Who wants to be hired?',
                  'https://news.ycombinator.com/submitted?id=whoishiring')
    elif include == 'freelance':
        rss = RSS(api.who_is_hiring(include),
                  'whoishiring - Freelancer? Seeking freelancer?',
                  'https://news.ycombinator.com/submitted?id=whoishiring')
    return rss.response()
Example #15
0
def show():
    api = API.using_request(request)
    rss = RSS(api.show_hn(), 'Hacker News: Show HN',
              'https://news.ycombinator.com/shownew')
    return rss.response()
Example #16
0
def jobs():
    api = API.using_request(request)
    rss = RSS(api.jobs(), 'Hacker News: Jobs',
              'https://news.ycombinator.com/jobs')
    return rss.response()
Example #17
0
sites = [
    Taifua(),
    Kingmo(),
    Lolimay(),
    ShawnLuo(),
    OmegaXYZ(),
    Chenshuo(),
    CSDN(),
    Tinshine(),
    Sanghangning(),
    Jarviswwong(),
    JSPang(),
    YLink(),
    SecNews(),
    iMyShare(),
    RSS(),
]

threadLock = threading.Lock()
myclient = pymongo.MongoClient("mongodb://localhost:27017/")
mydb = myclient["blotter"]
document = mydb["friends"]


class Worker(threading.Thread):
    def __init__(self, fid, rss):
        # super()
        threading.Thread.__init__(self)
        self.fid = fid
        self.rss = rss
Example #18
0
def polls():
    api = API.using_request(request)
    rss = RSS(api.polls(), 'Hacker News: Polls')
    return rss.response()
Example #19
0
def show():
    api = API.using_request(request)
    rss = RSS(api.show_hn(), 'Hacker News: Show HN')
    return rss.response()
Example #20
0
def ask():
    api = API.using_request(request)
    rss = RSS(api.ask_hn(), 'Hacker News: Ask HN',
              'https://news.ycombinator.com/ask')
    return rss.response()
Example #21
0
def polls():
    api = API.using_request(request)
    rss = RSS(api.polls(), 'Hacker News: Polls')
    return rss.response()
Example #22
0
def frontpage():
    api = API.using_request(request)
    rss_title = 'Hacker News: Front Page'
    rss = RSS(api.frontpage(), rss_title, 'https://news.ycombinator.com/')
    return rss.response()
Example #23
0
def show():
    api = API.using_request(request)
    rss = RSS(api.show_hn(), 'Hacker News: Show HN', 'https://news.ycombinator.com/shownew')
    return rss.response()
Example #24
0
 def solver(self, url: str):
     return RSS().solver("%s/rss/list" % (url.strip("/")))
Example #25
0
def jobs():
    api = API.using_request(request)
    rss = RSS(api.jobs(), 'Hacker News: Jobs', 'https://news.ycombinator.com/jobs')
    return rss.response()
Example #26
0
def ask():
    api = API.using_request(request)
    rss = RSS(api.ask_hn(), 'Hacker News: Ask HN', 'https://news.ycombinator.com/ask')
    return rss.response()
Example #27
0
    def go(self, url=None):
        if url is None: url = self.varURL.get()

        contentWindow = tkinter.Toplevel()
        textContainer = tkinter.Text(contentWindow,
                                     wrap='word',
                                     height=25,
                                     width=100)
        contentClose = tkinter.Button(contentWindow,
                                      text='Close',
                                      command=contentWindow.destroy)

        textContainer.tag_add('default', '0.0')
        textContainer.tag_config('default', font=self.defaultFont)
        textContainer.tag_config('hyper',
                                 foreground='blue',
                                 underline=1,
                                 font=self.defaultFont)

        contentWindow.title('RSS Feed')
        contentWindow.grid()
        textContainer.grid(row=0, column=0, columnspan=2, padx=10, pady=10)
        contentClose.grid(row=1, column=1, pady=5)

        # scrollbar for textContainer - must have same grid options as parent
        textScroll = tkinter.Scrollbar(contentWindow)
        textScroll.grid(row=0, column=0, columnspan=2, sticky='nse')
        textScroll.config(command=textContainer.yview)
        textContainer.config(yscrollcommand=textScroll.set)

        hyperlink = hyperlinkManager(textContainer)

        try:
            feedString = ''
            feed = RSS(url)
            contentWindow.title(feed.feedTitle)
            separator = '--------------------\n'
            for r in feed.records():
                textContainer.insert(tkinter.INSERT, separator, 'default')
                if ['title'] and r['link']:
                    textContainer.insert(tkinter.INSERT, r['title'] + '\n',
                                         hyperlink.add(r['link']))
                else:
                    if r['title']:
                        textContainer.insert(tkinter.INSERT, r['title'] + '\n',
                                             'default')
                    if r['link']:
                        textContainer.insert(tkinter.INSERT, r['title'] + '\n',
                                             hyperlink.add(r['link']))
                if r['description']:
                    textContainer.insert(tkinter.INSERT,
                                         r['description'] + '\n', 'default')

        except urllib.error.HTTPError as e:
            self.errorBox(e, contentWindow.destroy)
        except urllib.error.URLError as e:
            self.errorBox(e, contentWindow.destroy)
        except ValueError as e:
            if url: self.errorBox(e, contentWindow.destroy)
            else: contentWindow.destroy()
        except xml.parsers.expat.ExpatError as e:
            self.errorBox(e, contentWindow.destroy)
Example #28
0
def frontpage():
    api = API.using_request(request)
    rss_title = 'Hacker News: Front Page'
    rss = RSS(api.frontpage(), rss_title, 'https://news.ycombinator.com/')
    return rss.response()
Example #29
0
def show():
    api = API.using_request(request)
    rss = RSS(api.show_hn(), 'Hacker News: Show HN')
    return rss.response()