1#+Title: Lindsay2#+SUBTITLE:3#+OPTIONS: toc:nil4#+HTML_LINK_UP:5#+HTML_LINK_HOME:67* Writings8+ [[./blog][Blog]]9+ [[https://nya.one/@lindsay][Fediverse]]1011* Contact12|------------+----------------------|13| Email | [[mailto:Linsen Zhou <i@lin.moe>][i@lin.moe]] |14| IRC | lindsay@irc.oftc.net |15| PGP Pubkey | [[./pubkey.txt][7EB223B9B0D814B9]] |1617* Friends18+ [[https://kaix.in/][KAIX.IN]]19+ [[https://qaq.land][qaqland's site]]2021* Articles from blog I follow22#+NAME: rssfeeds23#+begin_src elisp :exports none24'("https://7ji.github.io/feed.xml"25 "https://emersion.fr/blog/atom.xml"26 "https://eli.thegreenplace.net/feeds/all.atom.xml"27 "https://herbsutter.com/feed/"28 "https://shansing.com/feed/")29#+end_src3031#+begin_src python :exports results :eval yes :results raw :var feeds=rssfeeds32import asyncio33import aiohttp34import feedparser3536docs=[]3738async def rss_feed_to_orgdoc(session: aiohttp.ClientSession, feed_url:str, limit:int=3):39 async with session.get(feed_url) as response:40 text = await response.text()41 feed = feedparser.parse(text)42 entries = []4344 for entry in feed.entries:45 if entry.link: entries.append((entry.published_parsed, f"| [[{entry.link}][{entry.title}]] | [[{feed['feed']['link']}][{feed['feed']['title']}]]|"))46 return entries[:limit]4748async def main():49 tasks: list[asyncio.Task[object]] = []50 async with aiohttp.ClientSession() as session:51 async with asyncio.TaskGroup() as tg:52 for i in feeds:53 task = tg.create_task(rss_feed_to_orgdoc(session, i))54 tasks.append(task)55 docs=[]56 for t in tasks:57 docs += t.result()58 docs.sort(key=lambda i: i[0], reverse=True)59 docs = docs[:15]60 return '| Title | Site|\n|------------+----------------------|\n' + '\n'.join([i[1] for i in docs])6162return asyncio.run(main())63#+end_src