# 2261 pages in all page_num=2261 page=1 while page<=page_num: print('Downloading {} page'.format(page)) # Must be 3 ~12. for tr_num in range(3,13): d_everypage='//*[@id="datasource"]/div/table/tr['+str(tr_num)+']/td[9]/div/div/p[2]' download=driver.find_element_by_xpath(d_everypage).click() # Give 20 seconds per download time time.sleep(20) page += 1 page_sr=driver.find_element_by_xpath('//*[@id="pager1"]/div[2]/table/tr/td[7]/input') page_sr.clear() page_sr.send_keys(page) page_sr.send_keys(Keys.RETURN) time.sleep(3)