python - Pandas: Repeat function for current keyword if except -
i have built web scraper. program enters searchterm searchbox , grabs results. pandas goes through spreadsheet line-by-line in column retrieve each searchterm. sometimes page doesn't load properly, prompting refresh. i need way repeat function , try same searchterm if fails. right now, if return , go on next line in spreadsheet. import pandas pd selenium import webdriver selenium.webdriver.common.keys import keys df = pd.read_csv(searchterms.csv, delimiter=",") def scrape(searchterm): #loads url searchbox = driver.find_element_by_name("searchbox") searchbox.clear() searchbox.send_keys(searchterm) print "searching %s ..." % searchterm no_result = true while no_result true: try: #find results, grab them no_result = false except: #refresh page , above again current searchterm - how? driver.refresh() return pd.series([col1, col2]) df[["colum...