Search code examples
pythonweb-scrapingfindfindall

Python Bsoup find_all() empty list / find None


(sorry if im asking in a bad way but this is my first question on this site)

I really dont understand why I dont get anything out of find/find_all I used similar code on another url (also techpilot) and it works perfectly there. thank you in advance

from bs4 import BeautifulSoup
from urllib.request import urlopen

url = "https://www.techpilot.de/zulieferer-suchen?laserschneiden%202d%20(laserstrahlschneiden)"
page = urlopen(url)
html = page.read().decode("utf-8")
soup = BeautifulSoup(html, "html.parser")

cclass=soup.find("div",class_="fancyCompLabel")
print(cclass)

Solution

  • It seems that the current version of the referenced web page simply has no elements with that class name.

    In fact, there is even no such substring in the response:

    >>> import requests
    >>> resp = requests.get('https://www.techpilot.de/zulieferer-suchen?laserschneiden%202d%20(laserstrahlschneiden)')
    >>> 'fancyCompLabel' in resp.text
    False