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