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('blabliblub')
|
||||||
print('len', len(tree.xpath(fdb_conf_entry_list_parent)))
|
print('len', len(tree.xpath(fdb_conf_entry_list_parent)))
|
||||||
for n in range(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')
|
|
||||||
|
try:
|
||||||
name = tree.xpath(
|
name = tree.xpath(
|
||||||
fdb_conf_entry_list_parent
|
fdb_conf_entry_list_parent
|
||||||
|
+ "["
|
||||||
|
+ str(n+1)
|
||||||
|
+ "]"
|
||||||
+ fdb_conf_entry_list_child_name
|
+ fdb_conf_entry_list_child_name
|
||||||
)[n]
|
)[0]
|
||||||
|
|
||||||
|
except Exception as e:
|
||||||
|
print("name could not be parsed", e)
|
||||||
|
name = 'NONE'
|
||||||
|
|
||||||
|
try:
|
||||||
info = tree.xpath(
|
info = tree.xpath(
|
||||||
fdb_conf_entry_list_parent
|
fdb_conf_entry_list_parent
|
||||||
|
+ "["
|
||||||
|
+ str(n+1)
|
||||||
|
+ "]"
|
||||||
+ fdb_conf_entry_list_child_info
|
+ fdb_conf_entry_list_child_info
|
||||||
)[n]
|
)[0]
|
||||||
|
|
||||||
|
except Exception as e:
|
||||||
|
print("info could not be parsed", e, info)
|
||||||
|
info = 'NONE'
|
||||||
|
|
||||||
|
try:
|
||||||
period = tree.xpath(
|
period = tree.xpath(
|
||||||
fdb_conf_entry_list_parent
|
fdb_conf_entry_list_parent
|
||||||
|
+ "["
|
||||||
|
+ str(n+1)
|
||||||
|
+ "]"
|
||||||
+ fdb_conf_entry_list_child_period
|
+ fdb_conf_entry_list_child_period
|
||||||
)[n]
|
)[0]
|
||||||
|
print('period', period)
|
||||||
|
except Exception as e:
|
||||||
|
print("period could not be parsed", e, period)
|
||||||
|
period = 'NONE'
|
||||||
|
|
||||||
print('oi ', name)
|
try:
|
||||||
print('blablidubbiduub')
|
|
||||||
link = tree.xpath(
|
link = tree.xpath(
|
||||||
fdb_conf_entry_list_parent
|
fdb_conf_entry_list_parent
|
||||||
# + "["
|
+ "["
|
||||||
# + str(n)
|
+ str(n+1)
|
||||||
# + "]"
|
+ "]"
|
||||||
+ fdb_conf_entry_list_child_link
|
+ fdb_conf_entry_list_child_link
|
||||||
)[n]
|
)[0]
|
||||||
|
print('link', link)
|
||||||
|
|
||||||
print('oi' + name)
|
except Exception as e:
|
||||||
|
print("link could not be parsed", e, link)
|
||||||
|
link = 'NONE'
|
||||||
|
|
||||||
if len(name) > 0:
|
|
||||||
|
if len(name) > 0 and name != 'NONE':
|
||||||
dictionary_entry_list[n] = {}
|
dictionary_entry_list[n] = {}
|
||||||
dictionary_entry_list[n]["name"] = name
|
dictionary_entry_list[n]["name"] = name
|
||||||
dictionary_entry_list[n]["info"] = info
|
dictionary_entry_list[n]["info"] = info
|
||||||
|
|
Loading…
Reference in a new issue