{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Creating and consuming rss feeds." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ " !pip install feedparser feedgen" ] }, { "cell_type": "code", "execution_count": 11, "metadata": {}, "outputs": [], "source": [ " from feedgen.feed import FeedGenerator\n", " import feedparser\n", " from pathlib import Path\n", " import ipywidgets as W\n", " from IPython.display import display, Markdown\n", " from collections import UserDict\n", " import deathbeds\n", " import pandas\n", " from sidecar import Sidecar\n", " from deathbeds.__summarizing_notebooks_with_gensim import summarize" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "C:\\Anaconda3\\lib\\site-packages\\IPython\\core\\interactiveshell.py:2963: UserWarning: Discarding nonzero nanoseconds in conversion\n", " exec(code_obj, self.user_global_ns, self.user_ns)\n", "C:\\Anaconda3\\lib\\site-packages\\nbconvert\\filters\\datatypefilter.py:41: UserWarning: Your element with mimetype(s) dict_keys(['application/literallycanvas+json']) is not able to be represented.\n", " mimetypes=output.keys())\n" ] } ], "source": [ "feed = FeedGenerator()\n", "root = Path(deathbeds.__file__).parent\n", "paths = list(root.glob('[0-9]*.ipynb'))\n", "feed.id(str(root))\n", "feed.title(deathbeds.__name__)\n", "feed.author({'name': 'deathbeds'})\n", "feed.link(href=str(root))\n", "\n", "for path in paths:\n", " stats = path.stat()\n", " entry = feed.add_entry()\n", " entry.id(str(path))\n", " entry.title(' '.join(path.name.split('-')[3:]))\n", " entry.author( {'name':'deathbeds'} )\n", " entry.link(href=str(path))\n", " entry.description(summarize(path, ratio=.05).summary)\n", " entry.updated(pandas.to_datetime(stats.st_mtime_ns, utc=True).to_pydatetime())\n", "\n", "posts = feedparser.parse(feed.atom_str())" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [], "source": [ "df = pandas.Series(posts['entries']).apply(pandas.Series)" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", " | id | \n", "guidislink | \n", "link | \n", "title | \n", "title_detail | \n", "updated | \n", "updated_parsed | \n", "authors | \n", "author_detail | \n", "author | \n", "content | \n", "summary | \n", "links | \n", "
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
45 | \n", "c:\\users\\deathbeds\\deathbeds.github.io\\deathbe... | \n", "True | \n", "c:\\users\\deathbeds\\deathbeds.github.io\\deathbe... | \n", "Tracing edges of image text.ipynb | \n", "{'type': 'text/plain', 'language': None, 'base... | \n", "2018-07-19T17:10:30.512923+00:00 | \n", "(2018, 7, 19, 17, 10, 30, 3, 200, 0) | \n", "[{'name': 'deathbeds'}] | \n", "{'name': 'deathbeds'} | \n", "deathbeds | \n", "[{'type': 'text/plain', 'language': None, 'bas... | \n", "* plot the outlines over top of the labelled i... | \n", "[{'href': 'c:\\users\\deathbeds\\deathbeds.github... | \n", "
28 | \n", "c:\\users\\deathbeds\\deathbeds.github.io\\deathbe... | \n", "True | \n", "c:\\users\\deathbeds\\deathbeds.github.io\\deathbe... | \n", "Literate Markdown Kernel.ipynb | \n", "{'type': 'text/plain', 'language': None, 'base... | \n", "2018-07-26T19:52:31.588995+00:00 | \n", "(2018, 7, 26, 19, 52, 31, 3, 207, 0) | \n", "[{'name': 'deathbeds'}] | \n", "{'name': 'deathbeds'} | \n", "deathbeds | \n", "[{'type': 'text/plain', 'language': None, 'bas... | \n", "from deathbeds.__Literate_Markdown_Kernel impo... | \n", "[{'href': 'c:\\users\\deathbeds\\deathbeds.github... | \n", "