我正在尝试在页面上打印某个类的所有文本,但是找不到方法,
dmenuhtml = BeautifulSoup(dmenu, 'html.parser')
#print(dmenuhtml)
#using find function to parse through the html
allday_breakfast = dmenuhtml.find()
#converting to text
allday_breakfast2 = allday_breakfast.text.strip()
print ("The All Day Breakfast today features...\n")
print(allday_breakfast)
我对HTML不熟悉,所以不确定在查找括号中输入什么?
答案 0 :(得分:0)
a = [i.text for i in dmenuhtml.findAll('div',{'class':'/class_name/'})]
尝试类似这样的方法。您需要知道您的文本在html中的位置。