'Problem with getting the scraped data table Python


import requests
from bs4 import BeautifulSoup

url = 'https://crypto.com/price'
response = requests.get(url).text
soup = BeautifulSoup(response,"html.parser")
row = soup.find("tbody")
for x in row :
    a = str(x.text)
    print(a)







enter image description here

how does the data that gets scraped would scraped properly



Solution 1:[1]

I think something like this would get you in the ballpark:

table_body= soup.find("tbody")

for table_row in table_body :
    for table_column in table_row.findAll():
        for ele in table_column:
            if ele.name == 'div':print(table_column.get_text())

That site has a lot happening in the table, but this spits out pretty clean data. Likely there is a lot more you can do here, but at least this gets you values.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 JNevill