From 1c4764e67d5883f9d0b46c3d80752515b7d3efb2 Mon Sep 17 00:00:00 2001 From: Jason Schwarzenberger Date: Fri, 6 Nov 2020 09:30:15 +1300 Subject: [PATCH] sort sitemap feed by lastmod time. --- apiserver/feeds/news.py | 1 + 1 file changed, 1 insertion(+) diff --git a/apiserver/feeds/news.py b/apiserver/feeds/news.py index ae860b8..b788530 100644 --- a/apiserver/feeds/news.py +++ b/apiserver/feeds/news.py @@ -181,6 +181,7 @@ class Sitemap(_Base): soup = BeautifulSoup(markup, features='lxml') articles = soup.find('urlset').findAll('url') articles = list(filter(None, [a if a.find('lastmod') is not None else None for a in articles])) + articles.sort(key=lambda a: unix(a.find('lastmod')), reverse=True) links = [x.find('loc').text for x in articles] or [] links = list(set(links)) if excludes: