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] 现在测试下: 定义一个有元组的 ...
随机推荐
- Codeforces Round #437 (Div. 2, based on MemSQL Start[c]UP 3.0 - Round 2)
Problem A Between the Offices 水题,水一水. #include<bits/stdc++.h> using namespace std; int n; ]; i ...
- 重温数据结构:树 及 Java 实现(转)
转自:http://blog.csdn.net/u011240877/article/details/53193877 读完本文你将了解到: 什么是树 树的相关术语 根节点父亲节点孩子节点叶子节点如上 ...
- Mongodb - 二进制安装
0.概述 mongodb版本:4.0.2 linux版本:redhat 6.5 安装方式:二进制安装 1.关闭防火墙 /etc/init.d/iptables status/etc/init.d/ip ...
- hashCode方法的作用?
(1)前言,想要明白hashCode的作用,你必须要先知道Java中的集合. Java中的集合(Collection)有两类,一类是List,再有一类是Set. 前者集合内的元素是有序的,元素可以重复 ...
- 16,EasyNetQ-群集支持
EasyNetQ支持RabbitMQ群集,无需部署负载均衡器. 只需在连接字符串中列出群集的节点... var bus = RabbitHutch.CreateBus("host=ubunt ...
- Gephi可视化(二)
继在园子里写的<Gephi可视化(一)——使用Gephi Toolkit创建Gephi应用>介绍了如何使用Gephi Toolkit工具集进行可视化编程后,本篇对Gephi Toolkit ...
- IT常用英文术语解释发音
associations 联系; 协会( association的名词复数 ); 联合; (思想.感觉.记忆等的) 联想; 按色赛诶神 == desktop ˈdesktɒp 的思克头铺 英[ˈde ...
- 洛谷.3121.审查(AC自动机 链表)
题目链接 //删掉一个单词需要前移一段位置,用链表维护就好了 复杂度O(sum(len)) #include <cstdio> #include <cstring> #defi ...
- stm32与HC-SR04超声波传感器测距
首先,先来看一下这个模块的基本功能和原理. HC-SR04超声波测距模块可提供2cm-400cm的非接触式距离感测功能,测距精度可达高到3mm:模块包括超声波发射器.接收器与控制电路.像智能小车的测距 ...
- Linux学习笔记14—文件的压缩与打包
1..gz gzip 压缩工具压缩的文件 .bz2 bzip2 压缩工具压缩的文件 .tar tar 打包程序打包的文件(tar并没有压缩功能,只是把一个目录合并成一个文件) .tar.g ...