I have the following code which takes a list of domains from my Neo4j database, performs a lookup on the IP and then creates a relationship if one does not already exist. It works fine up until the last few line of code where the relationships are created. I'm getting the following error. I've confirmed that the lists have two items - the domain and IP so I'm not sure why its creating an error:
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
Here is the code:
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'])