原始代码:

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的更多相关文章

  1. Pandas to_sql TypeError: sequence item 0: expected str instance, dict found

    问题介绍 打印了一下数据格式,并未发现问题.如果说是字典实例引起的. 我猜测也是extra字段引起的,因为extra字段是一个json字段.根据网上的提示要对这样的格式进行强转str. 其他发现:pd ...

  2. TypeError: sequence item 1: expected str instance, int found

    Error Msg Traceback (most recent call last): File "E:/code/adva_code/my_orm.py", line 108, ...

  3. 关于Python json解析过程遇到的TypeError: expected string or buffer

    关于Python json解析过程遇到的问题:(爬取天气json数据所遇到的问题http://tianqi.2345.com/) part.1 url——http://tianqi.2345.com/ ...

  4. 解决:error: Cannot fetch repo (TypeError: expected string or buffer)

    同步源码,问题重现: Fetching project platform/external/libopus Fetching project repo error: Cannot fetch repo ...

  5. TypeError: Fetch argument 0.484375 has invalid type <class 'numpy.float32'>, must be a string or Tensor. (Can not convert a float32 into a Tensor or Operation.)

    报错: TypeError: Fetch argument 0.484375 has invalid type <class 'numpy.float32'>, must be a str ...

  6. TypeError: Fetch argument 0 has invalid type <type 'int'>, must be a string or Tensor. (Can not convert a int into a Tensor or Operation.)

    6月5日的時候,修改dilated_seg.py(使用tensorflow)出現了報錯: TypeError: Fetch argument 0 has invalid type <type ' ...

  7. TypeError: expected string or buffer的解决方法

    错误种类:TypeError: expected string or buffer 具体错误解释:这是因为返回的变量不是字符类型,而导致此错误 具体解决方法:在具体程序段前加if判断语句,判断程序返回 ...

  8. 导入json文件报错,TypeError expected string or buffer

    导入json文件报错,TypeError expected string or buffer 原因:用字符串赋值后,python会把双引号转换为单引号 import json data = [{&qu ...

  9. a=re.findall('b',c)报错提示:TypeError:expected string or buffer

    目的:想通过findall选取某个unicode编码的字符串列表(列表里面有元组) 问题:报错[TypeError:expected string or buffer] 现在测试下: 定义一个有元组的 ...

随机推荐

  1. 注册表键值明明存在OpenSubKey始终返回null,解决方案

    先上代码及实例 RegistryKey rsg = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Macromedia\FlashPaper Pri ...

  2. Tr A HDU1575

    矩阵基本算法 #include<cstdio> using namespace std; int n; struct matrix { int m[15][15]; }ans,base; ...

  3. 【Java】 剑指offer(60) n个骰子的点数

      本文参考自<剑指offer>一书,代码采用Java语言. 更多:<剑指Offer>Java实现合集   题目 把n个骰子扔在地上,所有骰子朝上一面的点数之和为s.输入n,打 ...

  4. fmod()函数 (对浮点数取模)

    头文件:#include <math.h> fmod() 用来对浮点数进行取模(求余),其原型为:    double fmod (double x); 设返回值为 ret,那么 x = ...

  5. poj 1797 最大最小路段【dijkstra】 (经典)

    <题目链接> 题目大意: Hugo Heavy要从城市1到城市N运送货物,有M条道路,每条道路都有它的最大载重量,问从城市1到城市N运送最多的重量是多少. 解题分析: 感觉这道题用dijk ...

  6. How to use Jackson to deserialise an array of objects

    first create a mapper : import com.fasterxml.jackson.databind.ObjectMapper; ObjectMapper mapper = ne ...

  7. IdentityServer4-主题

    一.Startup 二.定义Resources 三.定义Clients 四.登录 五.使用外部身份提供商登录 六.Windows身份验证 七.登出 八.注销外部身份提供商 九.联合注销 十.联合网关 ...

  8. 潭州课堂25班:Ph201805201 爬虫高级 第二课 sclapy 框架 (课堂笔记)

    win 下安装 sclapy 先安装 pip install wheel py 库下载地址:https://www.lfd.uci.edu/~gohlke/pythonlibs/#twisted 在这 ...

  9. Flask的使用

    一.路由系统 1.子域名的配置 """ 可传入的参数: @app.route('/user/<username>') @app.route('/post/&l ...

  10. Centos7 MongoDB-3.4

    MongoDB 是一个介于关系数据库和非关系数据库之间的产品,是非关系数据库当中功能最丰富,最像关系数据库的 关系型数据库遵循ACID规则 事务在英文中是transaction,和现实世界中的交易很类 ...