First off, list index being out of range does sound simple and self-explanatory... but looking around I can find no explanation for my situation; I am iterating through a list 19 items long and at the 9th item my console throws the "list index out of range" error". I am at a loss for explanations quite frankly...
*I am using phantomjs and selenium to scrape a webpage... THANKS IN ADVANCE!
# data list
# -------------------------------------------------------------------------------------
xpath = [
businessName,firstName,lastName,ubi,info,
licenseType,licenseNumber,licenseEffectiveDate,licenseExpirationDate,status,
bondProvider,bondNumber,bondAmount,bondEffectiveDate,bondEffectiveDate,insuranceProvider,
insuranceNumber,insuranceAmount,insuranceEffectiveDate,insuranceExpirationDate
]
data = [
"businessName","firstName","lastName","ubi","info",
"licenseType","licenseNumber","licenseEffectiveDate","licenseExpirationDate","status",
"bondProvider","bondNumber","bondAmount","bondEffectiveDate","bondEffectiveDate","insuranceProvider",
"insuranceNumber","insuranceAmount","insuranceEffectiveDate","insuranceExpirationDate"
]
#
#
# xpath check and grab function
# -------------------------------------------------------------------------------------
i = 0
while i <= len(data):
result = browser.find_element_by_xpath(xpath[i]).text #checks is xpath exists
print i
print data[i] + " = " + str(result)
i += 1
i <= data[i]supposed to do?for i in range(len(xpath)-1rather than a while loop.i <= data[i]. Guess it's a good thing that this becomes aTypeErrorin python 3.