I've been trying to learn Python (currently requests and beautifulsoup4) and I found a tutorial online
The issue is I keep getting the below error and cannot figure it out at all...
Any help would be appreciated!
Traceback (most recent call last): File "C:\Users\BillyBob\Desktop\Web Scrap.py", line 14, in title = a.string.strip() AttributeError: 'NoneType' object has no attribute 'strip'
Here is my code in case I made a mistake;
import requests from bs4 import BeautifulSoup result = requests.get("http://www.oreilly.com/") c = result.content soup = BeautifulSoup(c, "html.parser") samples = soup.find_all("a") samples[0] data = {} for a in samples: title = a.string.strip() data[title] = a.attrs['href']
stringattribute ofaisNone. You need to look over the documentation for BeautifulSoup and see what.find_all()returns.