У меня есть сценарий с этими двумя функциями:AttributeError: объект «NoneType» не имеет атрибут «раскол»
# Getting content of each page
def GetContent(url):
response = requests.get(url)
return response.content
# Extracting the sites
def CiteParser(content):
soup = BeautifulSoup(content)
print "---> site #: ",len(soup('cite'))
result = []
for cite in soup.find_all('cite'):
result.append(cite.string.split('/')[0])
return result
Когда я запускаю программу, у меня есть следующее сообщение об ошибке:
result.append(cite.string.split('/')[0])
AttributeError: 'NoneType' object has no attribute 'split'
Выход пробы :
URL: <URL That I use to search 'can be google, bing, etc'>
---> site #: 10
site1.com
.
.
.
site10.com
URL: <URL That I use to search 'can be google, bing, etc'>
File "python.py", line 49, in CiteParser
result.append(cite.string.split('/')[0])
AttributeError: 'NoneType' object has no attribute 'split'
Можете ли вы предоставить пример ввода параметра контента? – Bryan
'cite.string' возвращает вам' NoneType' – cppcoder
@cppcoder Как я могу избавиться от этой ошибки? – MLSC