Ho uno script con queste due funzioni:AttributeError: oggetto 'NoneType' non ha alcun attributo 'split'
# 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
Quando eseguo programma che ho il seguente errore: Esempio
result.append(cite.string.split('/')[0])
AttributeError: 'NoneType' object has no attribute 'split'
uscita :
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'
Si può fornire esempio di input per il parametro contenuti? – Bryan
'cite.string' ti restituisce un' NoneType' – cppcoder
@cppcoder Come posso eliminare questo errore? – MLSC