in plugins/asfdata.py [0:0]
def process_blog(feed, count, words, debug):
if debug:
print(f'blog feed: {feed}')
# See INFRA-23636: cannot check the page status, so just catch parsing errors
try:
content = requests.get(feed, timeout=REQUESTS_TIMEOUT).text
dom = xml.dom.minidom.parseString(content)
# dive into the dom to get 'entry' elements
entries = dom.getElementsByTagName('entry')
# we only want count many from the beginning
entries = entries[:count]
except xml.parsers.expat.ExpatError:
entries = []
except (requests.exceptions.ConnectionError, requests.exceptions.Timeout):
entries = []
v = [ ]
for entry in entries:
if debug:
print(entry.tagName)
# we may want content
content_text = ''
if words:
content_text = truncate_words(get_element_text(entry, 'content'), words)
# we want the title and href
v.append(
{
'id': get_element_text(entry, 'id'),
'title': get_element_text(entry, 'title'),
'content': content_text
}
)
if debug:
for s in v:
print(s)
return [ Blog(href=s['id'],
title=s['title'],
content=s['content'])
for s in v]