Reputation: 393
I am trying to extract a few data from table. When I run, the snippet, it displays 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))
Current Output:
trs = t.find('tbody').find_all('tr')
AttributeError: 'NoneType' object has no attribute 'find'
Upvotes: 1
Views: 259
Reputation: 56
There is an iframe inside the page, so you may want to change to URL to point to the iframe, like so:
url = 'https://bscscan.com/token/generic-tokenholders2?m=normal&a=0xe432afB7283A08Be24E9038C30CA6336A7cC8218&s=607632056056917372864817&sid=88a5d39ff88e8e3546993b9dbfc36d66&p=1'
Upvotes: 3