In the loop I loop through ip and useragent to parse the site, some of the ip do not respond and after that an exception is thrown, and the cycle goes on, so, how to make it so that after the exception it does not continue further, skipping the place where the exception occurred, and started again from the place where the exception occurred, but with a different ip, because otherwise it misses the page.
def main(): url = 'http://old.toto-info.co/DataService.svc/GetMaxPrizeCoupons' useragents = open("useragents.txt").read().split('\n') proxies = open("proxies.txt").read().split('\n') for i in range(0,200,20): try: a = (uniform(1, 2)) sleep(a) StartFroms = i useragent = "'" + choice(useragents) + "'" proxy = {'http': 'http://' + choice(proxies)} get_html(url,useragent,proxy,StartFroms) except: print("not working") if __name__ == '__main__': main()