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(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的更多相关文章
- Pandas to_sql TypeError: sequence item 0: expected str instance, dict found
问题介绍 打印了一下数据格式,并未发现问题.如果说是字典实例引起的. 我猜测也是extra字段引起的,因为extra字段是一个json字段.根据网上的提示要对这样的格式进行强转str. 其他发现:pd ...
- 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, ...
- 关于Python json解析过程遇到的TypeError: expected string or buffer
关于Python json解析过程遇到的问题:(爬取天气json数据所遇到的问题http://tianqi.2345.com/) part.1 url——http://tianqi.2345.com/ ...
- 解决:error: Cannot fetch repo (TypeError: expected string or buffer)
同步源码,问题重现: Fetching project platform/external/libopus Fetching project repo error: Cannot fetch repo ...
- 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 ...
- 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 ' ...
- TypeError: expected string or buffer的解决方法
错误种类:TypeError: expected string or buffer 具体错误解释:这是因为返回的变量不是字符类型,而导致此错误 具体解决方法:在具体程序段前加if判断语句,判断程序返回 ...
- 导入json文件报错,TypeError expected string or buffer
导入json文件报错,TypeError expected string or buffer 原因:用字符串赋值后,python会把双引号转换为单引号 import json data = [{&qu ...
- a=re.findall('b',c)报错提示:TypeError:expected string or buffer
目的:想通过findall选取某个unicode编码的字符串列表(列表里面有元组) 问题:报错[TypeError:expected string or buffer] 现在测试下: 定义一个有元组的 ...
随机推荐
- Linux 僵尸进程的筛选和查杀
一.筛选 ps -A -o stat,ppid,pid,cmd | grep -e '^[Zz]' 二.查杀 ps -A -o stat,ppid,pid,cmd | grep -e '^[Zz]' ...
- Python open详解
一.打开文件的模式有: 1.r,只读模式[默认]. 2.w,只写模式.[不可读,不存在则创建,存在则删除内容] 3.a,追加模式.[可读,不存在则创建,存在则只追加内容] 二.+ 表示可以同时读写某个 ...
- 【LeetCode】159. Longest Substring with At Most Two Distinct Characters
Difficulty: Hard More:[目录]LeetCode Java实现 Description Given a string S, find the length of the long ...
- C#连接数据库MD5数据库加密
创建StringHelper类 首先数据库里的资料是加密了的. 创建将指定的字符串加密为MD5密文方法 public static string ToMD5(string source){ Strin ...
- 二分搜索-HihoCoder1139
题目描述: 由于自己“想得太多”,导致自己读了半天题才理解了题意.我还以为索敌值会随着每一次到达战略点而减小,结果题意是索敌值是固定了的,并不会改变. 如下是我对题目中第一个案例的分析: 每个圆圈代表 ...
- 操作系统概述(os 笔记一)
操作系统概述 操作系统的目标和功能 1.目标:作为用户/计算机接口 计算机的使用人群大致可以分为三类,终端用户,程序开发者,操作系统设计人员. 对于终端用户,即应用程序的用户来说,他们通常不关注计 ...
- JAXB注解 @XmlRootElement 及XML文件解析详解
@Retention(value=RUNTIME) @Target(value=TYPE) public @interface XmlRootElement @Inherited @Retention ...
- asp.net core2.0学习笔记
一.Core 1,防止过度发布 2,Main 3,Startup 4,添加过滤器 5,依赖注入 6,中间件 7,静态文件 8,路由 9,环境 10,配置和选项 11,日志 12,使用Sesstion ...
- luogu P2657 [SCOI2009]windy数 数位dp 记忆化搜索
题目链接 luogu P2657 [SCOI2009]windy数 题解 我有了一种所有数位dp都能用记忆话搜索水的错觉 代码 #include<cstdio> #include<a ...
- 10.17 NOIP模拟赛
目录 2018.10.17 NOIP模拟赛 A 咒语curse B 神光light(二分 DP) C 迷宫maze(次短路) 考试代码 B 2018.10.17 NOIP模拟赛 时间:1h15min( ...