Home > other >  Of new, encountered the crawler code AttributeError great god 'NoneType' object has no att
Of new, encountered the crawler code AttributeError great god 'NoneType' object has no att

Time:12-26

Programming at the style of study is the crawler course, practice is this:
You need to crawl blog [everyone is spider-man], "the future has to (4) - Python learning advanced map" the default comment articles page, and print,
The article URL:
https://wordpress-edu-3autumn.localprod.oc.forchange.cn/all-about-the-future_04/

My code after you've written just climbed out of a data (I suspect may be find_all class writing problems), and then there is that is to say, can't show in the form of text completely
Can only show in the form of the tag, otherwise will be an error AttributeError: 'NoneType' object has no attribute 'text'

My code like this:
The import requests
The from bs4 import BeautifulSoup
Res=requests. Get (' https://wordpress-edu-3autumn.localprod.oc.forchange.cn/all-about-the-future_04/')
HTML=res. Text
Soup=BeautifulSoup (HTML, '. The HTML parser)
The items=soup. Find_all (class_='comments - area')
For the item in the items:
Kind=item. The find (' h2)
Idcode=item. The find (class_='comment - body)
Time=item. The find (' datetime)
The content=item. The find (class_='comment - the content)
Print (idcode kind, '\ n', '\ n' time, '\ n' content)
# here if I enter the print (kind. Text, '\ n' idcode. Text, '\ n' time. The text, '\ n', the text), will appear AttributeError: 'NoneType' object has no attribute 'text'
Ask god help see what reason be?
Crab crab

CodePudding user response:

You extracted is null, so there is no text attributes, to evaluate first

CodePudding user response:

Be bold, remove the word, the extracted is empty, so there is no text attributes,

CodePudding user response:

This kind of situation, upstairs say the phenomenon, but I did not say lies,
Congratulations, you have been up
  • Related