У меня есть следующий код, который берет список доменов из моей базы данных Neo4j, выполняет поиск по IP-адресу, а затем создает связь, если она еще не существует. Он отлично работает до последних нескольких строк кода, где создаются отношения. Я получаю следующую ошибку. Я подтвердил, что в списках есть два элемента - домен и IP, поэтому я не уверен, почему возникает ошибка:
File "C:\Python26\beta7_whois4j_monitor_debug.py", line 63, in createrels
rels1 = graph_db.get_or_create_relationships((whoisnodes[0], "links", whoisnodes[1]))
IndexError: list index out of range
Вот код:
whoisindex = graph_db.get_or_create_index(neo4j.Node, "whoisID")
domains = whoisindex.query("whoisID:*com")
for i in domains:
list1 = []
value1 = "{0}".format(i['whoisID'])
try:
e = socket.gethostbyname(value1)
except socket.gaierror:
e = 'exclude from list'
if e != 'exclude from list':
list1.append(value1)
list1.append(e)
for word in list1:
whoisnodes = []
whoisnodes.append(whoisindex.get_or_create("whoisID", word, "whoisID":word}))
rels1 = graph_db.get_or_create_relationships(
(whoisnodes[0], "links", whoisnodes[1]))
print "{0}".format(i['whoisID'])