Cannot grab few data from a table because of AttributeError: 'NoneType' object has no attribute 'find'

Cannot grab few data from a table because of AttributeError: 'NoneType' object has no attribute 'find'

我正在尝试从 table 中提取一些数据。当我 运行 片段时,它显示 AttributeError: 'NoneType' object has no attribute 'find'

import requests
from bs4 import BeautifulSoup

url = "https://bscscan.com/token/0xe432afB7283A08Be24E9038C30CA6336A7cC8218#balances"
r = requests.get(url)
soup = BeautifulSoup(r.text, 'lxml')
t = soup.find('table', class_='table table-md-text-normal table-hover')
trs = t.find('tbody').find_all('tr')
for tr in trs[:5]:
    print(list(tr.stripped_strings))

当前输出:

trs = t.find('tbody').find_all('tr')
AttributeError: 'NoneType' object has no attribute 'find'

页面内有一个iframe,所以你可能想改成URL指向iframe,像这样:

url = 'https://bscscan.com/token/generic-tokenholders2?m=normal&a=0xe432afB7283A08Be24E9038C30CA6336A7cC8218&s=607632056056917372864817&sid=88a5d39ff88e8e3546993b9dbfc36d66&p=1'