Hello everyone. I was wondering if somebody could solve this problem for me. I have a bot that is required to refresh and grab back times here is the code for that task :
def findNST(html):
NST = re.findall(r'<td id="nst">(.*) am', html)
if NST == []:
NST = re.findall(r'<td id="nst">(.*) pm', html)
p = re.compile('\d+')
Times = p.findall(NST[0])
return NST, Times
Im having an issue where its crashing becuase sometimes the site goes down for a sec or it gets a blank page and it doesnt grab the time this is the error I get :
Traceback (most recent call last):
File "C:\Python27\Bot folder\frankie\client.py", line 170, in <module>
main()
File "C:\Python27\Bot folder\frankie\client.py", line 140, in main
firststock, html1 = checkRS()
File "C:\Python27\Bot folder\frankie\client.py", line 105, in checkRS
NSTC, TimeC = findNST(html)
File "C:\Python27\Bot folder\frankie\client.py", line 50, in findNST
Times = p.findall(NST[0])
IndexError: list index out of range
Can someone please fix this for me? I am not a programmer, just someone looking for a quick fix. If its a hard task please let me know im not trying to have someone waste their time on me :(.