Read the arch news before Updating.
by teckk from LinuxQuestions.org on (#5CHMQ)
This will run from tty, in case you are X/wayland broken, or running without GUI.
Only needs python3, urllib and xml.etree
Code:#!/usr/bin/python
#Get the Arch Latest News
from xml.etree import ElementTree
from urllib import request
import re
#Make a user agent string for urllib to use
agent = ('Mozilla/5.0 (Windows NT 10.1; Win64; x64; rv:82.0) '
'Gecko/20100101 Firefox/82.0')
user_agent = {'User-Agent': agent}
class MakeList():
def __init__(self, url, fname):
#Get the xml to parse
req = request.Request(url, data=None, headers=user_agent)
html = request.urlopen(req)
tree = ElementTree.parse(html)
root = tree.getroot()
#Get tag data
tagA = root.findall('./channel/item/title')
tagB = root.findall('./channel/item/link')
tagC = root.findall('./channel/item/description')
tagD = []
#Append lines with separator
for a,b,c in zip(tagA,tagB,tagC):
tagD.extend([a.text, b.text, c.text, '_' * 70])
#Print and Write list to file
with open(fname, 'a') as f:
for line in tagD:
print('%s\n' % re.sub('<[^>]*>', '', line))
f.write('%s\n\n' % re.sub('<[^>]*>', '', line))
if __name__ == "__main__":
#Urls, log names
A = ('https://archlinux.org/feeds/news/', 'Arch_RSS.log')
B = ('file:///local/file/archfeed.xml', 'test.log')
#Choose RSS feed here
url, fname = A
MakeList(url, fname)


Only needs python3, urllib and xml.etree
Code:#!/usr/bin/python
#Get the Arch Latest News
from xml.etree import ElementTree
from urllib import request
import re
#Make a user agent string for urllib to use
agent = ('Mozilla/5.0 (Windows NT 10.1; Win64; x64; rv:82.0) '
'Gecko/20100101 Firefox/82.0')
user_agent = {'User-Agent': agent}
class MakeList():
def __init__(self, url, fname):
#Get the xml to parse
req = request.Request(url, data=None, headers=user_agent)
html = request.urlopen(req)
tree = ElementTree.parse(html)
root = tree.getroot()
#Get tag data
tagA = root.findall('./channel/item/title')
tagB = root.findall('./channel/item/link')
tagC = root.findall('./channel/item/description')
tagD = []
#Append lines with separator
for a,b,c in zip(tagA,tagB,tagC):
tagD.extend([a.text, b.text, c.text, '_' * 70])
#Print and Write list to file
with open(fname, 'a') as f:
for line in tagD:
print('%s\n' % re.sub('<[^>]*>', '', line))
f.write('%s\n\n' % re.sub('<[^>]*>', '', line))
if __name__ == "__main__":
#Urls, log names
A = ('https://archlinux.org/feeds/news/', 'Arch_RSS.log')
B = ('file:///local/file/archfeed.xml', 'test.log')
#Choose RSS feed here
url, fname = A
MakeList(url, fname)