changed code in entrylist data2dictionary to handle empty or missing xml elements
This commit is contained in:
parent
ff23c22e3c
commit
317ef99720
2 changed files with 54 additions and 27 deletions
Binary file not shown.
|
@ -218,35 +218,62 @@ class fdb_spider(object):
|
|||
print('blabliblub')
|
||||
print('len', len(tree.xpath(fdb_conf_entry_list_parent)))
|
||||
for n in range(len(tree.xpath(fdb_conf_entry_list_parent))):
|
||||
print('oi inside the loop')
|
||||
name = tree.xpath(
|
||||
fdb_conf_entry_list_parent
|
||||
+ fdb_conf_entry_list_child_name
|
||||
)[n]
|
||||
|
||||
info = tree.xpath(
|
||||
fdb_conf_entry_list_parent
|
||||
+ fdb_conf_entry_list_child_info
|
||||
)[n]
|
||||
|
||||
period = tree.xpath(
|
||||
fdb_conf_entry_list_parent
|
||||
+ fdb_conf_entry_list_child_period
|
||||
)[n]
|
||||
|
||||
print('oi ', name)
|
||||
print('blablidubbiduub')
|
||||
link = tree.xpath(
|
||||
fdb_conf_entry_list_parent
|
||||
# + "["
|
||||
# + str(n)
|
||||
# + "]"
|
||||
+ fdb_conf_entry_list_child_link
|
||||
)[n]
|
||||
|
||||
print('oi' + name)
|
||||
try:
|
||||
name = tree.xpath(
|
||||
fdb_conf_entry_list_parent
|
||||
+ "["
|
||||
+ str(n+1)
|
||||
+ "]"
|
||||
+ fdb_conf_entry_list_child_name
|
||||
)[0]
|
||||
|
||||
except Exception as e:
|
||||
print("name could not be parsed", e)
|
||||
name = 'NONE'
|
||||
|
||||
if len(name) > 0:
|
||||
try:
|
||||
info = tree.xpath(
|
||||
fdb_conf_entry_list_parent
|
||||
+ "["
|
||||
+ str(n+1)
|
||||
+ "]"
|
||||
+ fdb_conf_entry_list_child_info
|
||||
)[0]
|
||||
|
||||
except Exception as e:
|
||||
print("info could not be parsed", e, info)
|
||||
info = 'NONE'
|
||||
|
||||
try:
|
||||
period = tree.xpath(
|
||||
fdb_conf_entry_list_parent
|
||||
+ "["
|
||||
+ str(n+1)
|
||||
+ "]"
|
||||
+ fdb_conf_entry_list_child_period
|
||||
)[0]
|
||||
print('period', period)
|
||||
except Exception as e:
|
||||
print("period could not be parsed", e, period)
|
||||
period = 'NONE'
|
||||
|
||||
try:
|
||||
link = tree.xpath(
|
||||
fdb_conf_entry_list_parent
|
||||
+ "["
|
||||
+ str(n+1)
|
||||
+ "]"
|
||||
+ fdb_conf_entry_list_child_link
|
||||
)[0]
|
||||
print('link', link)
|
||||
|
||||
except Exception as e:
|
||||
print("link could not be parsed", e, link)
|
||||
link = 'NONE'
|
||||
|
||||
|
||||
if len(name) > 0 and name != 'NONE':
|
||||
dictionary_entry_list[n] = {}
|
||||
dictionary_entry_list[n]["name"] = name
|
||||
dictionary_entry_list[n]["info"] = info
|
||||
|
|
Loading…
Reference in a new issue