Python 如何解决'NoneType' object has no attribute '...'的问题


Python 如何解决’NoneType’ object has no attribute '…'的问题


用 Python + selenium 和Beautifulsoup 爬取MOCC中国大学慕课网上某网上课程的课堂评论,在爬取少量数据时不出现标题所示错误,在爬取大量数据(运用到翻页操作)时出现 ‘NoneType’ object has no attribute ‘text’ 的错误。请问各位大佬原因,和解决方法

// 
b1 = a1.find_all('div', attrs={'style': "z-index: 0;"})
	for bb in b1:
		c1 = bb.find_all('div', recursive=False)
		for c in c1:
			username = c.find('span', attrs={'class': "userInfo j-userInfo"})
			Dict_all["r_User_" + str(b1.index(bb)) + str(c1.index(c))] = username.text

你可能感兴趣的:(Python 如何解决'NoneType' object has no attribute '...'的问题)