コード:はAttributeErrorは: 'NoneType' オブジェクトは、Pythonには属性 '下' を持っていない3.4
import requests
from bs4 import BeautifulSoup
import operator
def start(url):
word_list =[]
source_code =requests.get(url).text
soup = BeautifulSoup(source_code)
for post_string in soup.find_all('a',{'class':'cb-skin-ads-link'}):
content = post_string.string
words = content.lower()
for each_word in words:
print(each_word)
word_list.append(each_word)
start('http://www.cricbuzz.com/live-cricket-scorecard/16445/gl-vs-rcb-qualifier-1-indian-premier-league-2016')
エラー:何らかの理由で
Traceback (most recent call last):
File "C:/Users/Shera/PycharmProjects/Begin/wordcount.py", line 15, in <module>
start('http://www.cricbuzz.com/live-cricket-scorecard/16445/gl-vs-rcb-qualifier-1-indian-premier-league-2016')
File "C:/Users/Shera/PycharmProjects/Begin/wordcount.py", line 10, in start
words = content.lower()
AttributeError: 'NoneType' object has no attribute 'lower'
あなたの質問はありますか? –
'content'は' string'ではありません... – henrikstroem
そのアンカータグにはテキストがありませんので、実際に何を解析しようとしていますか? –