码迷,mamicode.com
首页 > 其他好文 > 详细

TypeError: sequence item 0: expected string, Tag found

时间:2018-11-27 19:21:14      阅读:235      评论:0      收藏:0      [点我收藏+]

标签:rac   sequence   cal   frame   attrs   expected   last   ast   squid   

原始代码:

soup = BeautifulSoup(result, html.parser)
content_list = soup.find_all(p, attrs={"class": "art_p"})
content = <br/>.join(content_list)

 

报错内容是:

Traceback (most recent call last):
  File "G:/squid_frame/app_spider/spider_3_sina/sina_2_content_spider.py", line 169, in <module>
    sina_content_spider(item=item)
  File "G:/squid_frame/app_spider/spider_3_sina/sina_2_content_spider.py", line 107, in sina_content_spider
    content = <br/>.join(content_list)
TypeError: sequence item 0: expected string, Tag found

 

解决办法:

soup = BeautifulSoup(result, html.parser)
content_list = soup.find_all(p, attrs={"class": "art_p"})
content =  <br>.join(str(ii) for ii in content_list)

 

TypeError: sequence item 0: expected string, Tag found

标签:rac   sequence   cal   frame   attrs   expected   last   ast   squid   

原文地址:https://www.cnblogs.com/xuchunlin/p/10027960.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!