概述
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
此代码用于从网站提取评论.我只需要文本 – 但我用div标签得到它们.
关于如何单独提取文本,我需要帮助.我需要单独的文本 – 在div类标签之间.
for row in soup.find_all('div',attrs={"class" : "reviewText"}): print row.text
要么:
[row.text for row in rows]
总结
以上是编程之家为你收集整理的Python:BeautifulSoup通过其类提取div标签之间的字符串全部内容,希望文章能够帮你解决Python:BeautifulSoup通过其类提取div标签之间的字符串所遇到的程序开发问题。
如果您也喜欢它,动动您的小指点个赞吧