svbtikk
svbtikk

Reputation: 15

Get text from <span class: with Beautifulsoup and requests

so I tried to get a specific text from a website but it only gives me the error (floor = soup.find('span', {'class': 'text-white fs-14px text-truncate attribute-value'}).text AttributeError: 'NoneType' object has no attribute 'text')

I specifically want to get the 'Floor Price' text.

My code:

import bs4
from bs4 import BeautifulSoup

#target url
url = "https://magiceden.io/marketplace/solsamo"
#act like browser
headers = {'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.95 Safari/537.36'}

response = requests.get('https://magiceden.io/marketplace/solsamo')
#parse the downloaded page
soup = BeautifulSoup(response.content, 'lxml')

floor = soup.find('span', {'class': 'text-white fs-14px text-truncate attribute-value'}).text

print(floor)

Upvotes: 0

Views: 493

Answers (1)

Oleksii Tambovtsev
Oleksii Tambovtsev

Reputation: 2844

There is no needed data in HTML you receive after:

response = requests.get('https://magiceden.io/marketplace/solsamo')

You can make sure of this by looking at page source code:

view-source:https://magiceden.io/marketplace/solsamo

You should use Selenium instead requests to get your data or you can examine XHR-requests on this page, maybe you can get this data using requests by following other link.

Upvotes: 0

Related Questions