0

I am doing scraping with butifulsoup module in python

My Code:

for cactus in cactus_product:
    price = cactus.find("span", class_="._89yzn").text
    title = cactus.find("span", class_="._2tW1I").text

    f.write(title + "," + price)

error

Traceback (most recent call last):
  File "C:\Users\Technicalsmirchis\python_scraping_tutorial\scraper.py", line 24, in <module>
    price = cactus.find('span', class_="_89yzn").text
AttributeError: 'NoneType' object has no attribute 'text'

1 Answers1

1

It's because the find function returned None, meaning it did not find the required element. you can add a try-except block in order to check for such exceptions or a if x is not None:

Tamir
  • 1,224
  • 1
  • 5
  • 18