[Python] BeautifulSoup table data extraction - data not showing up

Discussão em 'Python' iniciado por Stack, Fevereiro 18, 2025.

  1. Stack

    Stack Membro Participativo

    The problem that I am having is that the data needed is not showing up when running the Python code. It is visbile when I "inspect element" on Chrome but not "View Source".

    My code:

    import bs4 as bs
    import urllib
    import urllib.request
    url='https://ethplorer.io/address/0x8b353021189375591723e7384262f45709a3c3dc'
    page=urllib.request.urlopen(url)
    soup=bs.BeautifulSoup(page,'html.parser')

    cat=0
    for category in soup.findAll('td',{'class':'list-field'}):
    print(category)
    cat=cat+1


    It pulls out the needed line

    <td class="list-field" id="address-token-holdersCount"></td>


    However it has a value for it, which is the 2345 as shown below.

    When I check the page using "Inspect Element", the needed part looks like this:

    <table class="table">
    <tbody>
    <tr class="even last">
    <td>Holders</td>
    <td id="address-token-holdersCount"
    class="list-field">"2345"</td>
    </tr>
    </tbody>
    </table>


    What do you recommend to fix this issue?

    Continue reading...

Compartilhe esta Página