2021年3月31日星期三

Selenium: Reload page when ValueError: No tables found

How to trigger selenium to try and reload the url once before moving on to the next url?

Code:

if __name__ == '__main__':        results = None        for url in urls:          game_data = parse_data(url)          if game_data is None:              continue          result = pd.DataFrame(game_data.__dict__)          if results is None:              results = result          else:              results = results.append(result, ignore_index=True)  

Sometimes when the page does not load correctly (for some reason), it returns an error:

raise ValueError("No tables found")  ValueError: No tables found  

How to trigger selenium to try and reload the url once before moving on to the next url in the list when such an error occurs?

Thanks

https://stackoverflow.com/questions/66897946/selenium-reload-page-when-valueerror-no-tables-found April 01, 2021 at 11:12AM

没有评论:

发表评论