Hi, @dunhill
Maybe I'm wrong, but I think you may have translated your original code to Spanish and then back to English. This caused some problem with python syntax getting changed, like 'try' to 'attempt'.
Here is a working code, returning a 'float':
Code:
def scrape (isbn):
from bs4 import BeautifulSoup as bs
import requests
url = "https://www.tematika.com/catalogsearch/result/?q=" + isbn
r = requests.get(url)
soup = bs(r.text, 'html.parser')
div = soup.find(id='jm-current-content')
try:
pricebox = div.find_all(class_="price-box")
if len(pricebox) == 1:
for p in pricebox:
pricerange = p.find(class_="price")
return float(pricerange.text.replace('$', '').replace('.','').replace(',' , '.'))
else:
return none
except:
return none
P.S.: ISBN here is assumed to be a string, so I didn't change this.