当从纳斯达克刮取数据时,有像ACHC这样的具有空页面的代码。 ACHC Empty FieldSelenium Webdriver Timeout(Python 2.7)
我的程序遍历所有的股票代码,当我到达这个股票时,它会超时,因为没有数据需要掌握。我试图找出一种方法来检查是否没有任何内容,如果是这样,跳过这个代码,但继续循环。该代码是很长,所以生病后最相关的部分:循环开始时它打开的页面:
## navigate to income statement annualy page
url = url_form.format(symbol, "income-statement")
browser.get(url)
company_xpath = "//h1[contains(text(), 'Company Financials')]"
company = WebDriverWait(browser, 10).until(EC.presence_of_element_located((By.XPATH, company_xpath))).text
annuals_xpath = "//thead/tr[th[1][text() = 'Period Ending:']]/th[position()>=3]"
annuals = get_elements(browser,annuals_xpath)
Here is a pic of the error message
美丽!!!!!! – PurexedPose