mercredi 13 février 2019

A list in python contains companies ticker symbols. If a particular symbol information is not present on NASDAQ, how can I pass over to next symbol?

A list in python contains companies ticker symbols. If a particular symbol information is not present on NASDAQ, how can I pass over to next symbol?

Like for example, a particular symbol ("GOOG") balance sheet information is not available on NASDAQ. How can I skip that symbol and move to next one to gather information. I am iterating SNP 100 companies list.

I am trying with the if-else statement, it isn't working.

url_form = "http://www.nasdaq.com/symbol/{}/financials?query={}" financials_xpath = "//tbody/tr/th[text() = '{}']/../td[contains(text(), '$')]"

for i, symbol in enumerate(symbols):

## navigate to income statement annual 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

quarter_endings_xpath = "//thead/tr[th[1][text() = 'Period Ending:']]/th[position()>=3]"
quarter_endings = get_elements(quarter_endings_xpath)

if quarter_endings and financials_xpath == None:
      continue
  else:
      pass

Aucun commentaire:

Enregistrer un commentaire