import urllib,urllib2 from bs4 import BeautifulSoup,Comment url='http://www.amazon.in/product-reviews/B00CE2LUKQ/ref=cm_cr_pr_top_link_1?ie=UTF8&showViewpoints=0&sortBy=bySubmissionDateDescending' content = urllib2.urlopen(url).read() soup = BeautifulSoup(content,"html.parser") rows =soup.find_all('div',attrs={"class" : "reviewText"}) print rows
解决方法
for row in soup.find_all('div',attrs={"class" : "reviewText"}): print row.text
要么:
[row.text for row in rows]