Issue
I am trying to grab table data and found out that its dynamic and from an iframe. My snippet does not work. Any idea of help will be very useful.
from selenium import webdriver
import requests
from bs4 import BeautifulSoup
browser = webdriver.Chrome('C://Python38/chromedriver')
browser.get("https://poocoin.app/rugcheck/0xe56842ed550ff2794f010738554db45e60730371/top-holders")
url = "https://poocoin.app/rugcheck/0xe56842ed550ff2794f010738554db45e60730371/top-holders"
r = requests.get(url)
soup = BeautifulSoup(r.text, 'lxml')
t = soup.find('table', class_='table table-bordered table-condensed text-small')
trs = t.find('tbody').find_all('tr')
for tr in trs[:10]:
print(list(tr.stripped_strings))
browser.quit()
Current Output/Error:
Traceback (most recent call last):
File "C:/Users/Acer/poocoin.py", line 8, in <module>
trs = t.find('tbody').find_all('tr')
AttributeError: 'NoneType' object has no attribute 'find'
Solution
The webpage is dynamic but the table is not a part of any <iframe>
. The table is a part of the current webpage.
Here I have tried to extract the data from the table you need.
import requests
from bs4 import BeautifulSoup
import time
from selenium import webdriver
driver = webdriver.Chrome('chromedriver.exe')
url = 'https://poocoin.app/rugcheck/0xe56842ed550ff2794f010738554db45e60730371/top-holders'
driver.get(url)
time.sleep(8)
soup = BeautifulSoup(driver.page_source, 'lxml')
t = soup.find('table', class_='table table-bordered table-condensed text-small')
# Get all the rows from the table
trs = t.find_all('tr')
for tr in trs:
print(list(tr.stripped_strings))
['Address', 'Track Wallet', 'Type', 'Amount', 'Transfer Count', 'Current Balance']
['0xe432afb7283a08be24e9038c30ca6336a7cc8218', 'Contract', '2,047,063,909.1119', '14488', '74,050,430.9257']
['0xa36b9dc17e421d86ddf8e490dafa87344e76125b', 'Track', 'Wallet', '1,000,000,000.0000', '1', '49,463,154.0462']
['0x0eb207b525dc856c3bad5bfd7a7a4aae781e1757', 'Contract', '800,000,000.0000', '1', '3,620,000.0000']
['0xeaed594b5926a7d5fbbc61985390baaf936a6b8d', 'Contract', '150,526,843.9538', '1', '150,000,000.0000']
['0xe56842ed550ff2794f010738554db45e60730371', 'Contract', '148,413,174.7757', '14495', '9,165,152.5432']
['0xbbda05ea467ad348212dade5c38c11910c14e83e', 'Track', 'Wallet', '65,442,888.2752', '2093', '61,246,203.1985']
['0x537d90d1d2743f44b65612c9fff3b6f011f65471', 'Track', 'Wallet', '42,871,267.9652', '1', '3,919,432.0622']
['0x2def4d262bc8d7456c8d59138760c992283abf80', 'Track', 'Wallet', '42,411,193.5197', '1', '0.0000']
['0xab2feac90728c278b30c6597760d74eb57b3726f', 'Track', 'Wallet', '42,411,193.5197', '1', '0.0000']
['0xc1e16013a158d57a60d6aa5bb3108722b0ac6df5', 'Contract', '27,101,254.6006', '18', '0.0000']
['0xcfdb8569fb546a010bb22b5057679c4053d4a231', 'Track', 'Wallet', '26,328,593.9564', '7', '11,493,129.6564']
['0x000159831a681a63b01911b9c162fbb8949976ba', 'Contract', '23,385,665.4517', '1', '0.4517']
['0x8f3e8ab6cc8b3d565564256cce95ba9f213c2a0d', 'Track', 'Wallet', '21,880,000.0000', '21', '0.0000']
['0xc590175e458b83680867afd273527ff58f74c02b', 'Contract', '20,386,615.2880', '173', '0.0000']
['0xdb6f1920a889355780af7570773609bd8cb1f498', 'Contract', '19,065,071.3715', '2', '0.0000']
['0x112ac5463b46ba4f32b95ae733f73c6e23bd3e53', 'Track', 'Wallet', '17,982,140.3274', '7', '0.0074']
['0xa8b398896d67cea6d26fc140e056f745261c4b00', 'Track', 'Wallet', '17,933,245.4310', '21', '9,024,167.7594']
['0x2368b6acc957339cf34a08a064830fcdfcac02c6', 'Track', 'Wallet', '17,675,714.5003', '1', '8.5003']
['0x7cacd11be7d7c95c48a0477875d31040ddaff2da', 'Track', 'Wallet', '17,467,065.9791', '1', '0.0000']
['0xc62184ac04a0610147bd890ba32d1918b67e017c', 'Track', 'Wallet', '16,841,462.6819', '1', '2.6819']
Answered By - Ram Answer Checked By - Mary Flores (PHPFixing Volunteer)
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.