This is my code for creating a url list and Im getting an index out of range error? Please help!
#! /usr/bin/env python
import re
TOTAL_PAGES = 619
idFile = open("listOfURLs2", "r")
outFile = open("output", "w")
idList = []
urlList = []
temp = ""
tempStr = ""
currentList = []
index = 1
for line in idFile:
idList.append(line)
for i in range(TOTAL_PAGES): #iterates through all input files
try:
f = open('detailedData/exchange_view.php?id=' + str(idList[index][:-1]), 'r')
fullFile = f.read()
except IndexError,e:
print e
temp = re.search('Publics_mPage=\d*">\d*</a> of.*?(\d*) ', fullFile, re.S)
if temp is not None:
i = 1
while i <= int(temp.group(1)):
tempStr = "https://www.example.com/private/exchange_view.php?id=" + \
idList[index][:-1] + "&peerParticipantsPublics_mPage=" + str(i)
currentList.append(tempStr)
i += 1
else:
pass
index += 1
for line in currentList:
outFile.write(line)
outFile.write(' ')