[Python] BeautifulSoup can't find the class in nasdaq table

Discussão em 'Python' iniciado por Stack, Janeiro 30, 2025.

  1. Stack

    Stack Membro Participativo

    I am trying to scrape data from nasdaq earning calendar.

    URL = "https://www.nasdaq.com/market-activity/earnings"


    What I want is to get all the table actually, but first, I started to try how do I do this So I tried to scrape symbols. Html that contains the symbol is like this:


    <div part="table-cell" role="cell" class="table-cell
    fixed-column-size-50px
    text-align-left">
    <!--?lit$8289700385$--><a href="/market-activity/stocks/aapl/earnings">AAPL</a>
    </div>

    when I copy the name of the class by clicking 2 times on it, and paste it to python code, resulting code is:

    class_name = """table-cell
    fixed-column-size-50px
    text-align-left"""
    table_cell = soup.find_all("div", {"class": class_name})


    I also tried:

    class_name = "table-cell fixed-column-size-50px text-align-left"


    Lastly, I typed and executed $0.className in the console and it returned:

    'table-cell\n fixed-column-size-50px\n text-align-left'


    I also put it as class_name but it didn't work too. I am not familiar with html, so I searched for class rules but I couldn't find a solution that solves my case.

    Continue reading...

Compartilhe esta Página