Ejemplo n.º 1
0
class FeedGenerator(object):
    def __init__(self, **kwargs):
        self.feed = Feed()
        self.header = FEED_HEADER

        for k, v in kwargs.items():
            self.add_meta(k,v)

    def add_meta(self, label, val):
        self.feed.feed[label] = val

    def add_item(self, title, link, desc='', pub_date='', post_id=''):
        self.feed.items.append({
            'title': title,
            'link': link,
            'description': desc,
            'pubDate': pub_date.utctimetuple() if pub_date else None,
            'guid': post_id,
        })

    def render(self, format='rss'):
        if format.lower().count('atom'):
            feed_str = self.feed.format_atom_string()
        else:
            feed_str = self.feed.format_rss2_string()

        return FEED_TEMPLATE % (self.header, feed_str)        

    def rss(self):
        return self.render('rss')

    def atom(self):
        return self.render('atom')
Ejemplo n.º 2
0
def initFeed():
	newFeed = FeedFormatter()
	newFeed.feed['title'] = PEANUT_TITLE
	newFeed.feed["link"] = PEANUT_URL
	newFeed.feed["author"] = PEANUT_AUTHOR
	newFeed.feed["description"] = PEANUT_DESCRIPTION
	return newFeed
Ejemplo n.º 3
0
class FeedGenerator(object):
    def __init__(self, **kwargs):
        self.feed = Feed()
        self.header = FEED_HEADER

        for k, v in kwargs.items():
            self.add_meta(k, v)

    def add_meta(self, label, val):
        self.feed.feed[label] = val

    def add_item(self, title, link, desc='', pub_date='', post_id=''):
        self.feed.items.append({
            'title': title,
            'link': link,
            'description': desc,
            'pubDate': pub_date.utctimetuple() if pub_date else None,
            'guid': post_id,
        })

    def render(self, format='rss'):
        if format.lower().count('atom'):
            feed_str = self.feed.format_atom_string()
        else:
            feed_str = self.feed.format_rss2_string()

        return FEED_TEMPLATE % (self.header, feed_str)

    def rss(self):
        return self.render('rss')

    def atom(self):
        return self.render('atom')
Ejemplo n.º 4
0
    def get(self):
        feed = Feed()
        blog_name = self.request.get('blog_name')
        blog = Blog.query(Blog.name == blog_name).fetch()
        posts = Post.query(Post.blog_key == blog_key(blog_name)).order(
            -Post.edit_time).fetch()

        feed.feed['title'] = "Rss blog feed"
        feed.feed[
            'link'] = "http://blogger-kcl.appspot.com/?blog_name=" + blog[
                0].name
        feed.feed['author'] = blog[0].authors[0]
        feed.feed[
            'description'] = "This is a simple feed of blog " + blog[0].name

        feed.feed['guid'] = "123456789"
        feed.feed['blog_name'] = blog[0].name
        feed.feed['imgs_url'] = ['url1', 'url2', 'url3']

        for post in posts:
            item = {}
            item['guid'] = str(post.blog_key.urlsafe())
            item['title'] = post.title
            item['link'] = "http://blogger-kcl.appspot.com/?blog_name=" + blog[
                0].name + "&post_id=" + str(post.key.id())
            item['description'] = post.content
            item['imgs_url'] = post.imgs_url
            item['pubDate'] = time.mktime(post.create_time.timetuple())
            feed.items.append(item)

        rss = JINJA_ENVIRONMENT.get_template('rss.html')
        self.response.write(rss.render({'rssstr': feed.format_rss2_string()}))
Ejemplo n.º 5
0
def initFeed():
    newFeed = FeedFormatter()
    newFeed.feed['title'] = PEANUT_TITLE
    newFeed.feed["link"] = PEANUT_URL
    newFeed.feed["author"] = PEANUT_AUTHOR
    newFeed.feed["description"] = PEANUT_DESCRIPTION
    return newFeed
Ejemplo n.º 6
0
    def get(self):
        feed = Feed()
        blog_name = self.request.get('blog_name')
        blog = Blog.query(Blog.name == blog_name).fetch()
        posts = Post.query(Post.blog_key == blog_key(blog_name)).order(-Post.edit_time).fetch()

        feed.feed['title'] = "Rss blog feed"
        feed.feed['link'] = "http://blogger-kcl.appspot.com/?blog_name=" + blog[0].name
        feed.feed['author'] = blog[0].authors[0]
        feed.feed['description'] = "This is a simple feed of blog " + blog[0].name
        
        feed.feed['guid'] = "123456789"
        feed.feed['blog_name'] = blog[0].name
        feed.feed['imgs_url'] = ['url1', 'url2', 'url3']

        for post in posts:
            item = {}
            item['guid'] = str(post.blog_key.urlsafe())
            item['title'] = post.title
            item['link'] = "http://blogger-kcl.appspot.com/?blog_name=" + blog[0].name + "&post_id=" + str(post.key.id())
            item['description'] = post.content
            item['imgs_url'] = post.imgs_url
            item['pubDate'] = time.mktime(post.create_time.timetuple())
            feed.items.append(item)

        rss = JINJA_ENVIRONMENT.get_template('rss.html')
        self.response.write(rss.render({
            'rssstr': feed.format_rss2_string()
        }))
Ejemplo n.º 7
0
def feedsrss(ids_raw):
    ''' get a bunch of feeds posts as an RSS stream '''

    ids = []
    feed_names = []

    for i in ids_raw.split(','):
        try:
            feedid = int(i)
            if feedid in ids:
                continue

            feed = Feed.get(id=feedid)
            ids.append(feedid)
            feed_names.append(feed.name)
        except ValueError:
            continue
        except Feed.DoesNotExist:
            continue

    time_now = now()
    feed_posts = [p for p in \
                  Post.select().join(Feed).where(
                      (Feed.id << ids)
                      &(Post.status == 0)
                      &(Post.active_start < time_now)
                      &(Post.active_end > time_now)
                      &(Post.published)
                      )]

    feed = RSSFeed()

    feed.feed["title"] = ",".join(feed_names)
    feed.feed["link"] = url_for('feeds')
    feed.feed["description"] = "Posts from " + (','.join(feed_names))

    for post in feed_posts:
        contents = json.loads(post.content)
        cleantext = bleach.clean(contents["content"], tags=[], strip=True)
        if len(cleantext) > 20:
            cleantext = cleantext[0:20] + "..."

        item = {
            "title": cleantext,
            "description": contents["content"],
            "guid": str(post.id),

            }
        feed.items.append(item)

    resp = make_response(feed.format_rss2_string())
    resp.headers["Content-Type"] = "application/xml"

    return resp
Ejemplo n.º 8
0
def feedsrss(ids_raw):
    ''' get a bunch of feeds posts as an RSS stream '''

    ids = []
    feed_names = []

    for i in ids_raw.split(','):
        try:
            feedid = int(i)
            if feedid in ids:
                continue

            feed = Feed.get(id=feedid)
            ids.append(feedid)
            feed_names.append(feed.name)
        except ValueError:
            continue
        except Feed.DoesNotExist:
            continue

    time_now = now()
    feed_posts = [p for p in \
                  Post.select().join(Feed).where(
                      (Feed.id << ids)
                      &(Post.status == 0)
                      &(Post.active_start < time_now)
                      &(Post.active_end > time_now)
                      &(Post.published)
                      )]

    feed = RSSFeed()

    feed.feed["title"] = ",".join(feed_names)
    feed.feed["link"] = url_for('feeds')
    feed.feed["description"] = "Posts from " + (','.join(feed_names))

    for post in feed_posts:
        contents = json.loads(post.content)
        cleantext = bleach.clean(contents["content"], tags=[], strip=True)
        if len(cleantext) > 20:
            cleantext = cleantext[0:20] + "..."

        item = {
            "title": cleantext,
            "description": contents["content"],
            "guid": str(post.id),

            }
        feed.items.append(item)

    resp = make_response(feed.format_rss2_string())
    resp.headers["Content-Type"] = "application/xml"

    return resp
Ejemplo n.º 9
0
Archivo: main.py Proyecto: mcaudy/tubes
def generate_stream_atom(username=None):
    """generate an atom feed from the notices of an user
    """
    feed = Feed()

    if username is None:
        notices = stream
        feed.feed["title"] = "live stream"
        feed.feed["link"] = DOMAIN + "/atom/stream/"
        feed.feed["author"] = DOMAIN
    else:
        notices = user_notices.get(username, None)
        feed.feed["title"] = username + "'s stream"
        feed.feed["link"] = DOMAIN + "/atom/stream/" + username
        feed.feed["author"] = username

    if notices is None:
        return tubes.Response('nothing to see here, please move along', 404)

    for notice in notices:
        item = {}
        item["title"] = notice.title
        item["link"] = DOMAIN + "notice/" + notice.uid
        item["description"] = notice.body
        item["pubDate"] = notice.creation
        item["guid"] = notice.uid

        feed.items.insert(0, item)

    return feed.format_atom_string()
Ejemplo n.º 10
0
def feed(request):
    
    forum_name = request.matchdict.get('forum_name', None)
    
    if forum_name:
        forum = models.Forum.objects(name__iexact=forum_name).first()
        topics = models.Topic.objects(status='publish', tags__in=forum.tags).order_by("-published_date").limit(10)
    else:
        topics = models.Topic.objects(status='publish').order_by("-published_date").limit(10)

    # Create the feed
    feed = Feed()
    
    # Set the feed/channel level properties
    feed.feed["title"] = "Pumbaa feed"
    feed.feed["link"] = request.current_route_url()
    feed.feed["author"] = {'name' : "pumbaa"}
    feed.feed["description"] = "Pumbaa feed"
    feed.feed["update"] = datetime.datetime.now()
    
    for topic in topics:
        # Create an item
        item = {}
        item['title'] = topic.title
        item['link'] = request.route_url('forums.topics.view', topic_id=topic.id, title=topic.title)
        item['description'] = topic.description
        item['pubDate'] = topic.published_date
        item['guid'] = request.route_url('forums.topics.view', topic_id=topic.id, title=topic.title)
        item['category'] = ", ".join(topic.tags)
        item['author'] = {'name' : topic.author.username}
        
        # Add item to feed
        feed.items.append(item)
    
    return Response(feed.format_atom_string())
Ejemplo n.º 11
0
    def render(self):
        feed = FeedGenerator()
        feed.feed["title"] = self.site["main"]["title"]
        feed.feed["author"] = self.site["main"]["author"]
        feed.feed["link"] = self.site["main"]["url"]

        for entry in self.entries:
            feed.items.append({
                "title": entry.title,
                "link": "%s%s" % (feed.feed["link"], entry.item.location),
                "pubDate": entry.published_date.timetuple(),
                "guid": entry.item.location,
            })

        return feed.format_atom_string()
Ejemplo n.º 12
0
    def get(self):
        # Create the feed
        feed = Feed()

        # Set the feed/channel level properties
        feed.feed["title"] = "pkt.li"
        feed.feed["author"] = "pkt.li"
        feed.feed["link"] = "http://pkt.li/banks/rss"

        # Create items and add to the feed
        for item in rss_items:
            feed.items.append(item)

        # Print the feed to stdout in various formats
        self.content_type = 'application/atom+xml'
        self.write(feed.format_atom_string())
Ejemplo n.º 13
0
def create_feed(data):
	# Create the feed
	feed = Feed()

	# Set the feed/channel level properties
	feed.feed["title"] = data["title"]
	feed.feed["link"] = data["permalink_url"]
	feed.feed["author"] = data["user"]["username"]
	feed.feed["description"] = data["description"]
	feed.feed["image"] = data["tracks"][0]["artwork_url"]

	# Create an item
	for track in data["tracks"]:
	    item = {} # reset item object
	    pubDate = datetime.datetime.strptime(track["created_at"][:-6], '%Y/%m/%d %H:%M:%S')
	    item["title"] = track["title"]
	    item["enclosure"] = (
	        track["download_url"]+"?client_id="+SOUNDCLOUD_CLIENTID,
	        str(track["original_content_size"]))
	    item["description"] = track["description"]
	    item["guid"] = str(track["id"])
	    item["pubDate"] = pubDate.timetuple()
	    # Add item to feed
	    feed.items.append(item)

	# Print the feed to stdout in various formats
	return feed.format_rss2_string()
Ejemplo n.º 14
0
def construct_rss(channel_name, vods_info, display_name, add_live=True):
    feed = Feed()

    # Set the feed/channel level properties
    feed.feed["title"] = "%s's Twitch video RSS" % display_name
    feed.feed["link"] = "https://twitchrss.appspot.com/"
    feed.feed["author"] = "Twitch RSS Generated"
    feed.feed[
        "description"] = "The RSS Feed of %s's videos on Twitch" % display_name
    feed.feed["ttl"] = '10'

    # Create an item
    try:
        if vods_info:
            for vod in vods_info:
                item = {}

                # It seems if the thumbnail is empty then we are live?
                # Tempted to go in and fix it for them since the source is leaked..
                if vod["thumbnail_url"] == '':
                    if not add_live:
                        continue
                    link = "https://www.twitch.tv/%s" % channel_name
                    item["title"] = "%s - LIVE" % vod['title']
                    item["category"] = "live"
                    item["description"] = "<a href=\"%s\">LIVE LINK</a>" % link
                else:
                    link = vod['url']
                    item["title"] = vod['title']
                    item["category"] = vod['type']
                    item[
                        "description"] = "<a href=\"%s\"><img src=\"%s\" /></a>" % (
                            link, vod['thumbnail_url'].replace(
                                "%{width}", "512").replace("%{height}", "288"))
                item["link"] = link

                #@madiele: for some reason the new API does not have the game field anymore...
                #if vod.get('game'):
                #    item["description"] += "<br/>" + vod['game']

                if vod.get('description'):
                    item["description"] += "<br/>" + vod['description']
                d = datetime.datetime.strptime(vod['created_at'],
                                               '%Y-%m-%dT%H:%M:%SZ')
                item["pubDate"] = d.timetuple()
                item["guid"] = vod['id']
                if item["category"] == "live":  # To show a different news item when recording is over
                    item["guid"] += "_live"
                feed.items.append(item)
    except KeyError as e:
        logging.warning('Issue with json: %s\nException: %s' % (vods_info, e))
        abort(404)

    return feed.format_rss2_string()
Ejemplo n.º 15
0
    def construct_rss(self,
                      channel_name,
                      vods_info,
                      display_name,
                      add_live=True):
        feed = Feed()

        # Set the feed/channel level properties
        feed.feed["title"] = "%s's Twitch video RSS" % display_name
        feed.feed["link"] = "https://twitchrss.appspot.com/"
        feed.feed["author"] = "Twitch RSS Gen"
        feed.feed[
            "description"] = "The RSS Feed of %s's videos on Twitch" % display_name
        feed.feed["ttl"] = '10'

        # Create an item
        try:
            if vods_info['videos']:
                for vod in vods_info['videos']:
                    item = {}
                    if vod["status"] == "recording":
                        if not add_live:
                            continue
                        link = "http://www.twitch.tv/%s" % channel_name
                        item["title"] = "%s - LIVE" % vod['title']
                        item["category"] = "live"
                    else:
                        link = vod['url']
                        item["title"] = vod['title']
                        item["category"] = vod['broadcast_type']
                    item["link"] = link
                    item[
                        "description"] = "<a href=\"%s\"><img src=\"%s\" /></a>" % (
                            link, vod['preview']['large'])
                    if vod.get('game'):
                        item["description"] += "<br/>" + vod['game']
                    if vod.get('description_html'):
                        item[
                            "description"] += "<br/>" + vod['description_html']
                    d = datetime.datetime.strptime(vod['created_at'],
                                                   '%Y-%m-%dT%H:%M:%SZ')
                    item["pubDate"] = d.timetuple()
                    item["guid"] = vod['_id']
                    if vod["status"] == "recording":  # To show a different news item when recording is over
                        item["guid"] += "_live"
                    feed.items.append(item)
        except KeyError as e:
            logging.warning('Issue with json: %s\nException: %s' %
                            (vods_info, e))
            self.abort(404)

        return feed.format_rss2_string()
Ejemplo n.º 16
0
def get_feed(url_home, url_day):
    feed = Feed()

    feed.feed["title"] = FEED_TITLE
    feed.feed["link"] = url_home()
    feed.feed["description"] = FEED_DESCRIPTION
    feed.feed["author"] = FEED_AUTHOR

    tz = timezone(POST_NEW_ITEM_AT_TZ)
    now = datetime.datetime.now(tz)
    today = now.date()

    if now.time() < POST_NEW_ITEM_AT:  # don't post today's item yet
        today = today - datetime.timedelta(days=1)

    for i in range(1, DAYS_BACK + 1):
        date = today - datetime.timedelta(days=i)
        shots = service.popular_shots_of_day(date, SHOTS_PER_DAY)

        if not shots:  # skip the day if no shots are recorded
            continue

        pubDate = datetime.datetime(date.year, date.month, date.day,
                                    POST_NEW_ITEM_AT.hour,
                                    POST_NEW_ITEM_AT.minute,
                                    POST_NEW_ITEM_AT.second,
                                    tzinfo=tz)
        pubDate = pubDate + datetime.timedelta(days=1)

        item = {
            "title": "Popular designs of {0}".format(date.strftime("%b %d")),
            "link": url_day(date),
            "pubDate": pubDate.astimezone(UTC).timetuple(),
            "guid": url_day(date),
            "description": render_template('feed/shots.html', shots=shots,
                                           date=date)
        }
        feed.items.append(item)

    return feed
Ejemplo n.º 17
0
def atom_list_response(items, title, path, author):
    feed = Feed()

    feed.feed["title"] = title
    feed.feed["link"] = get_domain() + path
    feed.feed["author"] = author

    for msg in items:
        item = {}
        item[
            "title"] = "message from " + msg.user + " on " + msg.created.isoformat(
            )
        item["link"] = get_domain() + "/m/" + str(msg.key())
        item["description"] = msg.text
        item["pubDate"] = msg.created.timetuple()
        item["guid"] = str(msg.key())
        item["author"] = msg.user

        item["category"] = ["#" + val for val in msg.tags]
        item["category"] += ["@" + val for val in msg.mentions]

        feed.items.append(item)

    body = feed.format_atom_string()
    return flask.Response(body, 200, mimetype="application/atom+xml")
Ejemplo n.º 18
0
    def construct_rss(self, channel_name, vods_info):
        feed = Feed()

        # Set the feed/channel level properties
        feed.feed["title"] = "%s's Twitch video RSS" % channel_name
        feed.feed["link"] = "https://twitchrss.appspot.com/"
        feed.feed["author"] = "Twitch RSS Gen"
        feed.feed["description"] = "The RSS Feed of %s's videos on Twitch" % channel_name

        # Create an item
        try:
            if vods_info['videos'] is not None:
                for vod in vods_info['videos']:
                    item = {}
                    link = ""
                    if vod["status"] == "recording":
                        link = "http://www.twitch.tv/%s" % channel_name
                        item["title"] = "%s - LIVE" % vod['title']
                    else:
                        link = vod['url']
                        item["title"] = vod['title']
                    item["link"] = link
                    item["description"] = "<a href=\"%s\"><img src=\"%s\" /></a>" % (link, vod['preview'])
                    d = datetime.datetime.strptime(vod['recorded_at'], '%Y-%m-%dT%H:%M:%SZ')
                    item["pubDate"] = d.timetuple()
                    item["guid"] = vod['_id']
                    if vod["status"] == "recording": # To show a different news item when live is over
                        item["guid"] += "_live"
                    item["ttl"] = '10'
                    feed.items.append(item)
        except KeyError:
            self.abort(404)

        return feed.format_rss2_string()
Ejemplo n.º 19
0
    def doGo(self, result):
        feed = Feed()
        feed.feed["title"] = "Test Feed"
        feed.feed["link"] = "http://code.google.com/p/feedformatter/"
        feed.feed["author"] = "Luke Maurits"
        feed.feed["description"] = "A simple test feed for feedformatter"

        item = {"title": "Test item", "link": "http://www.python.org", "description": "Python programming language",
                "guid": "1234567890"}

        feed.items.append(item)

        atomFeed = AtomFeed()
        atomFeed.atom_id = "http://code.google.com/p/feedformatter/"
        atomFeed.atom_title = "Test Feed"
        atomFeed.atom_author = [{'name': 'Luke Maurits'}]
        atomFeed.atom_link = [{'href': "http://code.google.com/p/feedformatter/", 'rel': 'self', 'type': 'text/html'}]
        atomFeed.atom_subtitle = "A simple test feed for feedformatter"
        atomEntry = AtomEntry()
        atomEntry.atom_id = "1234567890"
        atomEntry.atom_title = "Test item"
        atomEntry.atom_content = {'content': "Python programming language", 'type': 'html'}
        atomEntry.atom_link = [{'href': "http://www.python.org", 'rel': 'self', 'type': 'text/html'}]
        atomFeed.feed_entries.append(atomEntry)
        atom, doc = atomFeed.build_atom_entry()
        atomString = ('<?xml version="1.0" encoding="UTF-8" ?>\n' + etree.tostring(atom, pretty_print=True))
        print('%s\n%s' % (atomString, feed.format_atom_string(pretty=True)))
        return atomString
    def find(self, query):
        # Create the feed
        feed = Feed()

        # Set the feed/channel level properties
        feed.feed["title"] = "Translate jobs search: %s" % query
        feed.feed["link"] = "http://www.diegotolentino.com"
        feed.feed["author"] = "Diego Tolentino"
        feed.feed["description"] = u'Extrator de trabalhos de tradução'

        # @todo Aparentemente o "pq(url=url)" da função get() sempre guarda o cache da primeira url lido, não lendo os demais, por isso sempre será lido somente a primeira pagina

        for i in [1]:
            # get itens of the page
            for item in self.get( "%s/cafe/SearchJobs.asp?Page=%s" % (self.url_base, i)):
                # If query match in item
                if query.lower() in item["description"].lower():
                    # Retrieving the complete description for item
                    html = pq(url=item["link"])
                    item["description"] = html('table.jobTbl td.thinborder').eq(2).html()

                    # Add item to feed
                    feed.items.append(item)

        # Return the feed in rss2 format
        return feed.format_rss2_string()
Ejemplo n.º 21
0
def create_feed_container(app):
    from feedformatter import Feed
    feed = Feed()
    feed.feed['title'] = app.config.project
    feed.feed['link'] = app.config.feed_base_url
    feed.feed['author'] = app.config.feed_author
    feed.feed['description'] = app.config.feed_description

    if app.config.language:
        feed.feed['language'] = app.config.language
    if app.config.copyright:
        feed.feed['copyright'] = app.config.copyright
    app.builder.env.feed_feed = feed
    if not hasattr(app.builder.env, 'feed_items'):
        app.builder.env.feed_items = {}
Ejemplo n.º 22
0
def atom_list_response(items, title, path, author):
    feed = Feed()

    feed.feed["title"] = title
    feed.feed["link"] = get_domain() + path
    feed.feed["author"] = author

    for msg in items:
        item = {}
        item["title"] = "message from " + msg.user + " on " + msg.created.isoformat()
        item["link"] = get_domain() + "/m/" + str(msg.key())
        item["description"] = msg.text
        item["pubDate"] = msg.created.timetuple()
        item["guid"] = str(msg.key())
        item["author"] = msg.user

        item["category"] = ["#" + val for val in msg.tags]
        item["category"] += ["@" + val for val in msg.mentions]

        feed.items.append(item)

    body = feed.format_atom_string()
    return flask.Response(body, 200, mimetype="application/atom+xml")
Ejemplo n.º 23
0
def make_feed():

    feed = Feed()
    
    feed.feed["title"] = app.config['FEED_TITLE']
    feed.feed["link"] = app.config['FEED_LINK']
    feed.feed["author"] = app.config['FEED_AUTHOR']
    feed.feed["description"] = app.config['FEED_DESC']

    entries = BlogEntry.select().order_by(('date', 'desc'), ).paginate(0, app.config['FEED_ITEMS'])

    for post in entries:
        item = {}

        item["title"] = post.title
        item["link"] = post.link
        item["description"] = post.summary
        
        item["pubDate"] = post.date.utctimetuple()
        item["guid"] = post.eid

        feed.items.append(item)

    return feed
Ejemplo n.º 24
0
def make_item_rss(title, row):
    # Create the feed
    feed = Feed()

    # Set the feed/channel level properties
    feed.feed["title"] = "STATUS - MID-coding on Mechanical Turk"
    feed.feed["link"] = "http://www.psu.edu"
    feed.feed["author"] = "The Pennsylvania State University"
    feed.feed["description"] = "An experiment - row retrieved"
    item = {}
    for (key, value) in row.items():
        item["mid:"+str(key)] = str(value)
    item["title"] = u"%s"%title
    feed.items.append(item)
    return feed.format_rss2_string()
Ejemplo n.º 25
0
def create_feed_container(app):
    from feedformatter import Feed
    feed = Feed()
    feed.feed['title'] = app.config.project
    feed.feed['link'] = app.config.feed_base_url
    feed.feed['author'] = app.config.feed_author
    feed.feed['description'] = app.config.feed_description
    
    if app.config.language:
        feed.feed['language'] = app.config.language
    if app.config.copyright:
        feed.feed['copyright'] = app.config.copyright
    app.builder.env.feed_feed = feed
    if not hasattr(app.builder.env, 'feed_items'):
        app.builder.env.feed_items = {}
Ejemplo n.º 26
0
def make_error_rss(s, id=None):
    # Create the feed
    feed = Feed()

    # Set the feed/channel level properties
    feed.feed["title"] = "STATUS - MID-coding on Mechanical Turk"
    feed.feed["link"] = "http://www.psu.edu"
    feed.feed["author"] = "The Pennsylvania State University"
    feed.feed["description"] = u"%s"%s
    item = {}
    item["title"] = u"%s"%s
    if id:
        item["mid:id"] = u"%s"%id
    item["source"] = u""
    feed.items.append(item)
    return feed.format_rss2_string()
    def doGo(self, result):
        feed = Feed()
        feed.feed["title"] = "Test Feed"
        feed.feed["link"] = "http://code.google.com/p/feedformatter/"
        feed.feed["author"] = "Luke Maurits"
        feed.feed["description"] = "A simple test feed for feedformatter"

        item = {
            "title": "Test item",
            "link": "http://www.python.org",
            "description": "Python programming language",
            "guid": "1234567890"
        }

        feed.items.append(item)

        atomFeed = AtomFeed()
        atomFeed.atom_id = "http://code.google.com/p/feedformatter/"
        atomFeed.atom_title = "Test Feed"
        atomFeed.atom_author = [{'name': 'Luke Maurits'}]
        atomFeed.atom_link = [{
            'href': "http://code.google.com/p/feedformatter/",
            'rel': 'self',
            'type': 'text/html'
        }]
        atomFeed.atom_subtitle = "A simple test feed for feedformatter"
        atomEntry = AtomEntry()
        atomEntry.atom_id = "1234567890"
        atomEntry.atom_title = "Test item"
        atomEntry.atom_content = {
            'content': "Python programming language",
            'type': 'html'
        }
        atomEntry.atom_link = [{
            'href': "http://www.python.org",
            'rel': 'self',
            'type': 'text/html'
        }]
        atomFeed.feed_entries.append(atomEntry)
        atom, doc = atomFeed.build_atom_entry()
        atomString = ('<?xml version="1.0" encoding="UTF-8" ?>\n' +
                      etree.tostring(atom, pretty_print=True))
        print('%s\n%s' % (atomString, feed.format_atom_string(pretty=True)))
        return atomString
Ejemplo n.º 28
0
    def feed(self, *args, **kwargs):
        name = os.path.sep.join(args) if args else None
        format = kwargs.get("format", "rss1")

        if not format in ("rss1", "rss2", "atom"):
            raise Exception("Invalid format %r" % format)

        feed = Feed()

        if name is not None:
            feed.feed["title"] = "%s :: %s" % (name, self.environ.site["name"])
        else:
            feed.feed["title"] = self.environ.site["name"]

        feed.feed["link"] = self.request.server.base
        feed.feed["author"] = self.environ.site["author"]
        feed.feed["description"] = self.environ.site["description"]

        if name is not None:
            history = list(self.storage.page_history(name))[:30]
            for rev, date, author, comment in history:
                item = {}
                item["title"] = "%s by %s" % (name, author)
                item["link"] = self.request.url(name)
                item["description"] = comment
                item["pubDate"] = date
                item["guid"] = str(rev)

                feed.items.append(item)
        else:
            history = list(self.storage.history())[:30]
            for name, rev, date, author, comment in history:
                item = {}
                item["title"] = "%s by %s" % (name, author)
                item["link"] = self.request.url(name)
                item["description"] = comment
                item["pubDate"] = date
                item["guid"] = str(rev)

                feed.items.append(item)

        self.response.headers["Content-Type"] = "application/xml"
        return getattr(feed, "format_%s_string" % format)()
Ejemplo n.º 29
0
    def get(self):
        # Create the feed
        feed = Feed()

        # Set the feed/channel level properties
        feed.feed["title"] = "pkt.li"
        feed.feed["author"] = "pkt.li"
        feed.feed["link"] = "http://pkt.li/banks/rss"

        # Create items and add to the feed
        for item in rss_items:
            feed.items.append(item)

        # Print the feed to stdout in various formats
        self.content_type = 'application/atom+xml'
        self.write(feed.format_atom_string())
Ejemplo n.º 30
0
def get_feed(url_home, url_day):
    feed = Feed()

    feed.feed["title"] = FEED_TITLE
    feed.feed["link"] = url_home()
    feed.feed["description"] = FEED_DESCRIPTION
    feed.feed["author"] = FEED_AUTHOR

    tz = timezone(POST_NEW_ITEM_AT_TZ)
    now = datetime.datetime.now(tz)
    today = now.date()

    if now.time() < POST_NEW_ITEM_AT:  # don't post today's item yet
        today = today - datetime.timedelta(days=1)

    for i in range(1, DAYS_BACK + 1):
        date = today - datetime.timedelta(days=i)
        shots = service.popular_shots_of_day(date, SHOTS_PER_DAY)

        if not shots:  # skip the day if no shots are recorded
            continue

        pubDate = datetime.datetime(date.year,
                                    date.month,
                                    date.day,
                                    POST_NEW_ITEM_AT.hour,
                                    POST_NEW_ITEM_AT.minute,
                                    POST_NEW_ITEM_AT.second,
                                    tzinfo=tz)
        pubDate = pubDate + datetime.timedelta(days=1)

        item = {
            "title":
            "Popular designs of {0}".format(date.strftime("%b %d")),
            "link":
            url_day(date),
            "pubDate":
            pubDate.astimezone(UTC).timetuple(),
            "guid":
            url_day(date),
            "description":
            render_template('feed/shots.html', shots=shots, date=date)
        }
        feed.items.append(item)

    return feed
Ejemplo n.º 31
0
    def feed(self, *args, **kwargs):
        name = os.path.sep.join(args) if args else None
        format = kwargs.get("format", "rss1")

        if not format in ("rss1", "rss2", "atom"):
            raise Exception("Invalid format %r" % format)

        feed = Feed()

        if name is not None:
            feed.feed["title"] = "%s :: %s" % (name, self.environ.site["name"])
        else:
            feed.feed["title"] = self.environ.site["name"]

        feed.feed["link"] = self.request.server.base
        feed.feed["author"] = self.environ.site["author"]
        feed.feed["description"] = self.environ.site["description"]

        if name is not None:
            history = list(self.storage.page_history(name))[:30]
            for rev, date, author, comment in history:
                item = {}
                item["title"] = "%s by %s" % (name, author)
                item["link"] = self.request.url(name)
                item["description"] = comment
                item["pubDate"] = date
                item["guid"] = str(rev)

                feed.items.append(item)
        else:
            history = list(self.storage.history())[:30]
            for name, rev, date, author, comment in history:
                item = {}
                item["title"] = "%s by %s" % (name, author)
                item["link"] = self.request.url(name)
                item["description"] = comment
                item["pubDate"] = date
                item["guid"] = str(rev)

                feed.items.append(item)

        self.response.headers["Content-Type"] = "application/xml"
        return getattr(feed, "format_%s_string" % format)()
Ejemplo n.º 32
0
def get_worker_response(assn_id):
    if assn_id:
        # Create the feed
        feed = Feed()

        # Set the feed/channel level properties
        feed.feed["title"] = "MID-coding on Mechanical Turk"
        feed.feed["link"] = "http://www.psu.edu"
        feed.feed["author"] = "The Pennsylvania State University"
        feed.feed["description"] = "An experiment - saved response"
        existing = connection.execute(assignments.select(assignments.c.id==assn_id)).first()
        if existing:
            item = {}
            for (key, value) in existing.items():
                item["mid:"+str(key)] = str(value)
            item["title"]       = str(assn_id)
            item["description"] = 'saved response' 
            feed.items.append(item)
            return feed.format_rss2_string()
        else:
            return make_error_rss("No assignment with requested ID")
    else:
        return make_error_rss("Assignment ID not given to web service")
Ejemplo n.º 33
0
    def get(self):
        from feedformatter import Feed
        import time
        feed = Feed()

        feed.feed["title"] = self.settings["blog_title"]
        feed.feed["link"] = self.settings["blog_url"]
        feed.feed["author"] = "*****@*****.**"
        feed.feed["description"] = u"C#, Objective-C, Python;"

        entities = db.Query(Entry).order("-published").fetch(limit=100)
        for x in entities:
            item = {}
            item["title"] = x.title
            item["link"] = self.settings["blog_url"] + "/post/" + str(x.key())
            item["description"] = x.slug
            item["pubDate"] = x.published
            item["guid"] = str(x.key())
            feed.items.append(item)

        self.set_header("Content-Type", "text/xml")
        self.write(feed.format_rss2_string())
Ejemplo n.º 34
0
def make_feed():

    feed = Feed()
    
    feed.feed["title"] = app.config['FEED_TITLE']
    feed.feed["link"] = app.config['FEED_LINK']
    feed.feed["author"] = app.config['FEED_AUTHOR']
    feed.feed["description"] = app.config['FEED_DESC']

    entries = BlogEntry.select().order_by(('date', 'desc'), ).paginate(0, app.config['FEED_ITEMS'])

    for post in entries:
        item = {}

        item["title"] = post.title
        item["link"] = post.link
        item["description"] = post.summary
        
        item["pubDate"] = post.date.utctimetuple()
        item["guid"] = post.eid

        feed.items.append(item)

    return feed
Ejemplo n.º 35
0
import feedparser
from feedformatter import Feed
import time

# Create the feed
feed = Feed()

# Set the feed/channel level properties
feed.feed["title"] = "Possibly important journal articles"
feed.feed["link"] = "http://www.etano.net/feelter.rss"
feed.feed["author"] = "Ethan W. Brown"
feed.feed[
    "description"] = "Aggregated articles from various scientific journals based on keywords."

# Set keywords
topics = [
    'path integral monte carlo', 'quantum annealing', 'quantum algorithm',
    'tensorflow', 'keras', 'word2vec', 'doc2vec', 'topic modeling',
    'named entity recognition', 'part of speech tagging'
]
people = [
    'David Ceperley', 'Matthias Troyer', 'Yann Lecun', 'Schmidhuber',
    'Edward Witten', 'Alexei Kitaev', 'Geoffrey Hinton', 'Andrew Ng',
    'Hugo Larochelle', 'Yoshua Bengio', 'Fei-Fei Li', 'Shane Legg',
    'Demis Hassabis', 'David Silver', 'Richard Sutton', 'Gerald Tesauro'
]
research_orgs = [
    'OpenAI', 'DeepMind', 'Facebook AI', 'Salesforce Research', 'Google Brain',
    'IBM Research', 'Microsoft Research', 'Baidu Research', 'Nvidia'
]
keywords = topics + people + research_orgs
Ejemplo n.º 36
0
def feed_for_docs(alist, appuri=""):  # takes a list of assignments, document IDs, or documents
    global LINK_PREFIX
    # must give assignments
    # Create the feed
    feed = Feed()

    # Set the feed/channel level properties
    feed.feed["title"] = "MID-coding on Mechanical Turk"
    feed.feed["link"] = "http://www.psu.edu"
    feed.feed["author"] = "The Pennsylvania State University"
    feed.feed["description"] = "An experiment - document retrieval"

    print "feed for docs alist=", alist
    for a in alist:
        aid = None
        atoken = None
        if 'doc' in a:
            doc = a.doc
            aid = a.id
            atoken = a.token
        else:
            doc = a
            
        if isinstance(doc, basestring):
            ds = connection.execute(docs.select().where(docs.c.key==doc))
        else:
            ds = [doc]

        if not ds:
            # print "ERROR - could not cross-reference document ", doc
            # print "- this is missing from docs table."
            return make_error_rss("ERROR - could not cross-reference document %s"%doc)
        for d in ds:
            # Create an item
#             item = {}
#             item["source"] = u""+d.source.rstrip()
#             item["mid:file"] = d.filename.rstrip()
#             item["mid:meta_date"] = d.meta_date.rstrip()
#             item["mid:meta_class"] = u"%s"%d.meta_class
#             item["mid:host_level"] = u"%s"%d.host_level
#             i = 0
#             for e in d.meta_entities.split(","):
#                 item["mid:meta_entity_%s"%i] = e
#                 i+=1
# 
            item = {}
            for (key, value) in d.items():
                if not isinstance(value, float):
                    if value is None:
                        item["mid:"+key] = 'none'
                    elif isinstance(value, ( int, long ) ):
                        item["mid:"+key] = str(value)
                    elif isinstance(value, datetime):
                        item["mid:"+key] = value.strftime('%B %-d, %Y')
                    else:
                        item["mid:"+key] = value
            item["title"] = u""+d.headline.rstrip()#.decode("utf8")
            #date = d.gskey.split('--')[0]
            #item["date"] = int(datetime.datetime.strptime(date, '%Y%m%d').strftime('%s'))
            item["link"] = u""+appuri+"?aid=%s&request=doc"%aid
            item["mid:token"] = u"%s"%atoken
            item["mid:aid"] = u"%s"%aid
            if not LINK_PREFIX:
                item["mid:text"] = u""+d.text #.decode("utf8")
            feed.items.append(item)
    # print len(feed.items)
    return feed.format_rss2_string()
Ejemplo n.º 37
0
fh.setFormatter(formatter)
log.addHandler(fh)

alert = Alert(sys.argv[1:9])

log.debug("Events=%d Search='%s' Trigger='%s' URL='%s' Raw results='%s'" %
          (alert.numevents, alert.fullsearch, alert.trigger_reason,
           alert.saved_search_url, alert.raw_results))
log.debug('%s' % pprint.pformat(alert.__dict__))

if os.path.isfile(FEED_RSS):
    # Read the current RSS feed
    feed_rss = open(FEED_RSS, "r+")
    fcntl.flock(feed_rss, fcntl.LOCK_EX)
    f = feedparser.parse(feed_rss.read())
    feed = Feed()

    feed.feed['title'] = f['feed']['title']
    feed.feed['link'] = f['feed']['link']
    feed.feed['description'] = f['feed']['description']

    # filter feed
    cut = datetime.now() - RSS_MAX_AGE
    for e in f['entries']:
        date = time.strptime(e['published'], '%a, %d %b %Y %H:%M:%S %Z')
        if datetime(*date[:6]) > cut:
            item = {}
            item['title'] = e['title']
            item['link'] = e['link']
            item['description'] = e['summary']
            item['pubDate'] = date
Ejemplo n.º 38
0
def getfeed(paths, sourcedir = 'blog'):
    "Make feed items out of paths"
    unsortedItems = []
    unsortedDates = []
    for path in paths:
        # Close the file from the previous iteration
        try:
            f.close()
        except NameError:
            pass

        f = open(path, 'r')

        # Title
        title = f.readline()[:-1]

        # h1
        if set('=') != set(f.readline()[:-1]):
            raise ValueError("The second line of %s contains characters other than equal-signs." % path)

        # Date
        dateline = f.readline()[:-1]
        if dateline.lower().strip() == 'draft':
            continue
        try:
            pubDate = datetime.datetime.strptime(dateline, '%B %d, %Y').timetuple()
        except ValueError:
            params = (path, datetime.date.today().strftime('%B %d, %Y'))
            raise ValueError('The third line of %s should be either the word "Draft" or a date in this format: %s.' % params)
        if pubDate > NOW:
            # Ignore dates in the future
            print('Skipping %s because its pubDate is in the future' % path)
            continue

        # Optional categories line
        categoriesline = f.readline().strip()
        if len(categoriesline) >= 12 and categoriesline[0:12] == 'Categories: ':
            categories = [category.strip() for category in categoriesline[12:].split(',')]
            emptyline = f.readline().strip()
        elif '' == categoriesline:
            categories = []
            emptyline = categoriesline
        else:
            raise ValueError('The fourth line of %s should say "Categories: " and then list of categories or be empty.' % path)
         
        # Empty line
        if '' != emptyline:
            raise ValueError("There should be an empty line between the header and body inside %s." % path)

        # Description
        try:
            description = misaka.html(f.read())
        except:
            print("Error parsing %s" % path)
            raise

        # Construct the link
        dirs = full_path_split(path, sourcedir = sourcedir)
        link = os.path.join(BLOG_ROOT, *dirs)

        # Append the item
        unsortedItems.append({
             'title': escape(title),
             'link': link,
             'guid': link,
             'description': escape(description),
             'pubDate': pubDate,
             'categories': categories
        })
        unsortedDates.append(pubDate)

    sortingHat = zip(unsortedDates, unsortedItems)
    sortingHat.sort(reverse = True)
    sortedDates, sortedItems = zip(*sortingHat)

    feed = Feed()
    feed.feed['title'] = "Thomas Levine"
    feed.feed['description'] = "Thomas Levine"
    feed.feed['lastBuildDate'] = NOW
    feed.feed['link'] = DOMAIN
    feed.items = sortedItems

    return feed
Ejemplo n.º 39
0
    result['date'] = findSection(imageHtml, 'btphp/comics/', '.gif')
    result['title'] = findSection(imageHtml, 'alt="', '"')
    result['url'] = 'http://sinfest.net/view.php?date=%s' % (result['date'])

    return result

try:
    todaysSinfest = getData('http://sinfest.net/')
except:
    today = datetime.date.today()
    todaysSinfest = {'title': 'could not fetch', 'url': '', 'imageUrl': '',
        'dateFormatted': today.strftime('%d %b %Y'),
        'date': today.strftime('%Y-%m-%d') }

# Create the feed.
feed = Feed()

# Set the feed/channel level properties.
feed.feed['title'] = 'Sinfest RSS'
feed.feed['link'] = 'http://www.sinfest.net'
feed.feed['author'] = 'Tatsuya Ishida'
feed.feed['description'] = 'RSS feed for Sinfest'

# Create an item.
# For this basic feed, I'll only include the latest comic.
item = {}
item['link'] = todaysSinfest['url']
item['guid'] = todaysSinfest['date']
item["pubDate"] = time.localtime()
item['title'] = 'Sinfest for %s: %s' % (todaysSinfest['dateFormatted'], todaysSinfest['title'])
if todaysSinfest['imageUrl'] != '':
Ejemplo n.º 40
0
argParser.add_argument('-l', type=int, help='Last n items (default:10)', default=10)
argParser.add_argument('-n', action='store_false', help='Disable lookup CPE name (default is True)')
argParser.add_argument('-r', action='store_true', help='Enable CVE ranking (default is False) and only print entries with ranking')
args = argParser.parse_args()

if args.l:
    last = args.l
else:
    last = 10

ref = "http://adulau.github.com/cve-search/"
cves = cves.last(rankinglookup = args.r, namelookup = args.n)

if not(args.f == "html"):
    from feedformatter import Feed
    feed = Feed()

    feed.feed['title'] = "cve-search Last "+str(last)+" CVE entries generated on "+str(datetime.datetime.now())
    feed.feed['link'] = "http://adulau.github.com/cve-search/"
    feed.feed['author'] = "Generated with cve-search available at http://adulau.github.com/cve-search/"
    feed.feed['description'] = ""
else:
    print ("<html><head>")
    print ("<style>.cve table { border-collapse: collapse; text-align: left; width: 100%; } .cve {font: normal 12px/150% Geneva, Arial, Helvetica, sans-serif; background: #fff; overflow: hidden; border: 1px solid #006699; -webkit-border-radius: 3px; -moz-border-radius: 3px; border-radius: 3px; }.cve table td, .cve table th { padding: 3px 10px; }.cve table tbody td { color: #00496B; border-left: 1px solid #E1EEF4;font-size: 12px;font-weight: normal; }.cve table tbody .alt td { background: #E1EEF4; color: #00496B; }.cve table tbody td:first-child { border-left: none; }.cve table tbody tr:last-child td { border-bottom: none; }.cve table tfoot td div { border-top: 1px solid #006699;background: #E1EEF4;} .cve table tfoot td { padding: 0; font-size: 12px } .cve table tfoot td div{ padding: 0px; }</style>")
    print ("<title>Last "+str(args.l)+" CVE entries</title>")
    print ("</head><body>")
for x in cves.get(limit=last):
    if not(args.f == "html"):
        if args.r:
            if not x['ranking']:
                continue
Ejemplo n.º 41
0
Archivo: kq.py Proyecto: caozhzh/rss
be = BeautifulSoup(page)
div = be.find('div', {'class': 'diywidget'})
txt = ''.join(div.findAll(text=True))
#print type(txt)

import feedparser
origin_feed = feedparser.parse('http://blog.sina.com.cn/rss/1696709200.xml')

from feedformatter import Feed
import time
import datetime
import uuid

# Create the feed
feed = Feed()

# Set the feed/channel level properties
feed.feed["title"] = u"孔青老师信息公告"
feed.feed["link"] = u"http://blog.sina.com.cn/u/1696709200"
feed.feed["author"] = u"自动获取工具"
feed.feed[
    "description"] = u"此RSS是由自动获取新浪博客信息公告的工具产生的,作者无法保证正确性,请以孔青老师博客公布的信息为准"

import json
lastmd5 = ""
try:
    with open('lastmd5.txt', 'r') as f:
        lastmd5 = json.load(f)
except:
    pass
Ejemplo n.º 42
0
args = argParser.parse_args()

if args.l:
    last_items = args.l
else:
    last_items = 10

ref = "http://adulau.github.com/cve-search/"
cvelist = CveHandler(rankinglookup=args.r,
                     namelookup=args.n,
                     capeclookup=args.c)

if not (args.f == "html"):
    from feedformatter import Feed

    feed = Feed()

    feed.feed["title"] = ("cve-search Last " + str(last_items) +
                          " CVE entries generated on " +
                          str(datetime.datetime.now()))
    feed.feed["link"] = "http://adulau.github.com/cve-search/"
    feed.feed[
        "author"] = "Generated with cve-search available at http://adulau.github.com/cve-search/"
    feed.feed["description"] = ""
else:
    print("<html><head>")
    print(
        "<style>.cve table { border-collapse: collapse; text-align: left; width: 100%; } .cve {font: normal 12px/150% "
        "Geneva, Arial, Helvetica, sans-serif; background: #fff; overflow: hidden; border: 1px solid #006699; "
        "-webkit-border-radius: 3px; -moz-border-radius: 3px; border-radius: 3px; }.cve table td, .cve table th { "
        "padding: 3px 10px; }.cve table tbody td { color: #00496B; border-left: 1px solid #E1EEF4;font-size: "
Ejemplo n.º 43
0

try:
    todaysSinfest = getData("http://sinfest.net/")
except:
    today = datetime.date.today()
    todaysSinfest = {
        "title": "could not fetch",
        "url": "",
        "imageUrl": "",
        "dateFormatted": today.strftime("%d %b %Y"),
        "date": today.strftime("%Y-%m-%d"),
    }

# Create the feed.
feed = Feed()

# Set the feed/channel level properties.
feed.feed["title"] = "Sinfest RSS"
feed.feed["link"] = "http://www.sinfest.net"
feed.feed["author"] = "Tatsuya Ishida"
feed.feed["description"] = "RSS feed for Sinfest"
# Suggest checking every 12 hours. Normally content will update every 24 hours.
# This is an attempt to tell clients there's no point checking the feed
# every 5 minutes - it's not a big deal load-wise, but it is pointless.
feed.feed["ttl"] = "720"

# Create an item.
# For this basic feed, I'll only include the latest comic.
item = {}
item["link"] = todaysSinfest["url"]
Ejemplo n.º 44
0
    def __init__(self, **kwargs):
        self.feed = Feed()
        self.header = FEED_HEADER

        for k, v in kwargs.items():
            self.add_meta(k, v)
Ejemplo n.º 45
0
from feedformatter import Feed
import time

# Create the feed
feed = Feed()

def indent(elem, level=0):
    i = "\n" + level*"  "
    if len(elem):
        if not elem.text or not elem.text.strip():
            elem.text = i + "  "
        if not elem.tail or not elem.tail.strip():
            elem.tail = i
        for elem in elem:
            indent(elem, level+1)
        if not elem.tail or not elem.tail.strip():
            elem.tail = i
    else:
        if level and (not elem.tail or not elem.tail.strip()):
            elem.tail = i

# Set the feed/channel level properties
feed.feed["title"] = "Example feed"
feed.feed["link"] = "http://www.example.com"
feed.feed["author"] = "Mr X. Ample"
feed.feed["description"] = "A simple example feed with one item in it"

# Create an item
item = {}
item["title"] = "Test item"
item["link"] = "http://www.example.com/example_url"
Ejemplo n.º 46
0
    help=
    'Enable CVE ranking (default is False) and only print entries with ranking'
)
args = argParser.parse_args()

if args.l:
    last = args.l
else:
    last = 10

ref = "http://adulau.github.com/cve-search/"
cves = cves.last(rankinglookup=args.r, namelookup=args.n)

if not (args.f == "html"):
    from feedformatter import Feed
    feed = Feed()

    feed.feed['title'] = "cve-search Last " + str(
        last) + " CVE entries generated on " + str(datetime.datetime.now())
    feed.feed['link'] = "http://adulau.github.com/cve-search/"
    feed.feed[
        'author'] = "Generated with cve-search available at http://adulau.github.com/cve-search/"
    feed.feed['description'] = ""
else:
    print("<html><head>")
    print(
        "<style>.cve table { border-collapse: collapse; text-align: left; width: 100%; } .cve {font: normal 12px/150% Geneva, Arial, Helvetica, sans-serif; background: #fff; overflow: hidden; border: 1px solid #006699; -webkit-border-radius: 3px; -moz-border-radius: 3px; border-radius: 3px; }.cve table td, .cve table th { padding: 3px 10px; }.cve table tbody td { color: #00496B; border-left: 1px solid #E1EEF4;font-size: 12px;font-weight: normal; }.cve table tbody .alt td { background: #E1EEF4; color: #00496B; }.cve table tbody td:first-child { border-left: none; }.cve table tbody tr:last-child td { border-bottom: none; }.cve table tfoot td div { border-top: 1px solid #006699;background: #E1EEF4;} .cve table tfoot td { padding: 0; font-size: 12px } .cve table tfoot td div{ padding: 0px; }</style>"
    )
    print("<title>Last " + str(args.l) + " CVE entries</title>")
    print("</head><body>")
for x in cves.get(limit=last):
Ejemplo n.º 47
0
Archivo: kq.py Proyecto: caozhzh/rss
be = BeautifulSoup(page)
div = be.find('div', {'class': 'diywidget'})
txt = ''.join(div.findAll(text=True))
#print type(txt)

import feedparser
origin_feed = feedparser.parse('http://blog.sina.com.cn/rss/1696709200.xml')

from feedformatter import Feed
import time
import datetime
import uuid

# Create the feed
feed = Feed()

# Set the feed/channel level properties
feed.feed["title"] = u"孔青老师信息公告"
feed.feed["link"] = u"http://blog.sina.com.cn/u/1696709200"
feed.feed["author"] = u"自动获取工具"
feed.feed["description"] = u"此RSS是由自动获取新浪博客信息公告的工具产生的,作者无法保证正确性,请以孔青老师博客公布的信息为准"

import json
lastmd5=""
try:
    with open('lastmd5.txt', 'r') as f:
        lastmd5 = json.load(f)
except:
    pass
Ejemplo n.º 48
0
    def __init__(self, **kwargs):
        self.feed = Feed()
        self.header = FEED_HEADER

        for k, v in kwargs.items():
            self.add_meta(k,v)
Ejemplo n.º 49
0
base_uri = "https://www.googleapis.com/plus/v1"

author_uri = "%s/people/%s?fields=displayName&key=%s" % (base_uri, user_id, public_key)

feed_uri = "%s/people/%s/activities/public?key=%s" % (base_uri, user_id, public_key)

def get_data(uri):
    req = Request(uri)
    req.add_header("Referer", public_host)
    r = urlopen(req)
    return json.load(r)

author = get_data(author_uri)['displayName']

feed = Feed()

feed.feed['title'] = author + " G+"
feed.feed['link'] = "https://plus.google.com/%s/posts" % (user_id)
feed.feed['author'] = author

for item in get_data(feed_uri)['items']:
    feed_item = {}
    feed_item['title']   = item['title']
    feed_item['url']     = item['url']
    feed_item['pubDate'] = time.strptime(item['published'].split(".")[0],
                                         "%Y-%m-%dT%H:%M:%S")
    feed_item['title']   = ""
    feed_item['content'] = item['object']['content']
    feed.items.append(feed_item)