There are some Web pages loading time is very long, Xinhua will never load, but need to crawl the information has been loaded out, if it is time to wait to continue is a waste.
There will likely be a long time to load the place try except,
If the page needs to crawl content has been loaded, even if the page does not load complete, except after the driver can also be used
From selenium.common.exceptions import timeoutexception
Why the from selenium.common.exceptions.TimeoutException as TimeoutException cannot point out timeoutexception
Try:try:driver.get ("https://c3.zgdhhjha.com/scholar/") Except Timeoutexception,e:print type (e) print ' Time Out in
Search Page ' try:driver.find_element_by_id (' Gs_hdr_tsi '). Send_keys (Line[i])
Driver.find_element_by_xpath ('//*[@id = ' gs_hdr_tsb ']/span/span[1] '). Click () A = Driver.find_element_by_xpath ('//*[@id = "Gs_res_ccl_mid"]/div/div[2]/div[3]/a[3] ') except Timeoute Xception, E:print ' Time Out in crawl page ' with open (' Citaresult.txt ', ' a ') a S Wfile:wfile.write (str (i+1) + ', ' +a.text+ ' \ n ') except Exception, e:# here, you can tell if it is
No such element exception print ' Exception: ', e print ' num: ', I, ' title: ', Line[i] Driver.closE () chromedriver = ' F:\chromedriver_win32\chromedriver.exe ' # Chromedriver's path to the OS. environ["Webdriver.chrome.driver"] = chromedriver Driver = webdriver. Chrome (Chromedriver)