I have download an RSS file and saved as city.txt
.
Then I have to grab the date from the <lastBuildDate>
tag.
The date is in the format: Fri,28 Aug 2020
and then I have to translate the day and month all using RegEx.
I have managed to get the date but I have problem changing the date and month after I have found it.
Do I have to use re.sub
?
My code:
import re
with open('city.txt', 'r', encoding = 'utf-8') as f:
txt = f.read()
tag_pattern =r'<''lastBuildDate'r'\b[^>]*>(.*?)</''lastBuildDate'r'>'
found = re.findall(tag_pattern, txt, re.I)
found = list(set(found))
for f in found :print('\t\t', f)