def getFirstPostData(forum_text):
soup = BeautifulSoup(forum_text)
title = ""
date = ""
body = ""
try:
date = soup.find("div", attrs={"class": "postDate"}).text
except AttributeError:
print "Date not found"
try:
title = soup.find("div", attrs={"class": "postTitle"}).text
except AttributeError:
print "Title not found"
try:
body = soup.find("div", attrs={"class": "postBody"}).text
except AttributeError:
print "Body not found, now this is weird"
return [title,date,body]
评论列表
文章目录