def find_table(htmlTree):
    logger.info("Finding the right table")
    ret = None
    tables = htmlTree.xpath("//table[@class='wikitable sortable']")
    for table in tables:
        headers = table.xpath("tr[1]/th")
        if len(headers) > 5:
            if headers[TICKER_SYMBOL_COL].xpath("a[1]")[0].text != "Ticker symbol":
                continue
            if headers[COMPANY_COL].text != "Company":
                continue
            if headers[GICS_COL].xpath("a[1]")[0].text != "GICS":
                continue
            if headers[GICS_SUB_INDUSTRY_COL].text != "GICS Sub Industry":
                continue
            ret = table
            break
    return ret
dataset/ETHPy150Open gbeced/pyalgotrade/tools/symbols/get_sp500_symbols.py/find_table/original