What i\'m trying to do is use beautiful soup to get the value of an html attribute.
What i have so far is:
soup = BeautifulSoup(html, \"html.parser\")
I assume your find()
method returns None
so you can't concatenate string at line #2.
>>> print('' + None)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: can only concatenate str (not "NoneType") to str
That's an error message I get in Python 3.7
That's not the Soup problem, you have to explicitly check return value.
Provide more information (stacktrace) if that's not the case
you should try the following
soup = BeautifulSoup(html, "html.parser")
print("data-sitekey=" + soup.find("div", attrs={"class" : "data-sitekey"}))
return soup.find("div", attrs={"class" : "data-sitekey"})