html_text = driver.page_source
soup = BeautifulSoup(html_text, "html.parser")
get_details = soup.find_all('li', attrs={"class":"news"})
# get_details is an aggregation of results fetched by BeautifulSoup find_all() method
one instance of the resultset is as below:
<li class="news">blah blah blah what i want blah blah blah <a href="/graphic/graphicInfoData/000002230030421305">View details</a></li>
What I want is the "blah blah blah what i want blah blah blah", the so-called Navigable string in BeautifulSoup. But I can not use .string attribute to a list, even when I use the print(get_details[0].string), the result is None, why?
by the way , as a comparison, below code works!
print(get_details[0].a.string)
>>> print(get_details[0].li.string)
Traceback (most recent call last):
File "<pyshell#57>", line 1, in <module>
print(get_details[0].li.string)
AttributeError: 'NoneType' object has no attribute 'string'
Any thoughts will be highly appreciated!
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…