I'm trying to webscrape some information with python from an online database and put it into one data file in the end. at the moment I'm iterating through a database. At first I tested it for some specific websites it worked just fine, when I ran each line separately, but when I try to run the whole code it doesn't work anymore. I've now realized that the problem is that the code doesn't download the information fast enough, i.e. in this code excerpt, between line 2 and 3 there is the problem which causes it to got to except.
try:
download = driver.find_element(By.XPATH,'...').click()
oldfile = old_path + 'file.xlsx'
newfile = 'output/FederalExperience_'+z1+'.xlsx'
shutil.move(oldfile,newfile)
except:
print("No such section")
Is there a way to tell the code to only run, when the file is downloaded? or some other way to make it work? I'm using a mac and vscode btw.
except:
like that. You don't know what the error that's happening is – chances are it's not about slowness at all. For instance, it could be aMemoryError
if you're running out of memory, or anOSError
if themove()
fails. (It could even be you pressing ctrl+c – that'd raise aKeyboardInterrupt
!) - AKXexcept
withexcept Exception as e
and then in the next line:print(type(e).__name__, e)
You will get info what's actual error. - Mikaelblomkvistssontry:except:
around your code and tell us what the actual error is you're getting. - AKX