Python 爬虫 数据清洗 去掉 超链接
有时候我们需要清洗数据,里面有超链接,怎么去掉他们,比如下面的问题
<div class="lot-page-details"><ul class="info-list"><li class="lot-info-item"><p><strong class="section-header">Provenance</strong></p><p>Brand New
Gallery, Milan<br/>Acquired from the above by the present owner</p></li><li class="lot-info-item"><p><strong class="section-header">Exhibited</strong>
</p><p>Milan, Brand New Gallery, <em>This is the story of America. Everybody's doing what they think they're supposed to do</em>, November ,
- January , </p></li><li class="artist-biography"><p><strong class="section-header">Artist Bio
</strong></p><a href="/artist/12106/ethan-cook"><h4>Ethan Cook</h4></a><p class="artist-info">American •
</p><div class="follow-artist" data-artist-id=""
role="button"
tabindex="">
<span cl
ass="icon"></
span><s
pan class=
"toolti
p">Follow</span></div><div class="artist-bio"><p> <p>New York-based artist Ethan Cook is known for his abstract paintings on self-produced canvases. More recently, he has used handwoven strips of
cotton and linen to create painterly compositions. Cook's woven canvases are contemporary in their minimalist focus on shape and color while referencing
one of the most traditional art forms, weaving. Cook weaves his own canvases on a
loom and juxtaposes these with
store-bought canvas sheets
in abstract arrangements.
For the artist,
the surface of th
e canvas itself becomes the foc
us of his practice. Using simple geometric shapes and a l
imited color palate, Cook's works nurture structural s
implicity.</p></p><a href="/artist/12106/ethan-cook"><div class="lot-essay-button artist"><em>View More Works</em></div></a></div></li></ul></div>
第一种方法:
用这则替换,把 href 替换为 hre1f 就可以了,
第二种方法:
result_div_list = re.findall('<(.*?)>',str(result_div))
if 'href' in str(result_div_list):
for ii in result_div_list:
if 'href' in ii:
item_desc = str(result_div).replace(str(ii) ,'')
else:
item_desc = result_div
记录下来,供以后学习参考
Python 爬虫 数据清洗 去掉 超链接的更多相关文章
- python 爬虫(转,我使用的python3)
原文地址:http://blog.csdn.net/pi9nc/article/details/9734437 [Python]网络爬虫(一):抓取网页的含义和URL基本构成 分类: 爬虫 Pyt ...
- 我的第一个Python爬虫——谈心得
2019年3月27日,继开学到现在以来,开了软件工程和信息系统设计,想来想去也没什么好的题目,干脆就想弄一个实用点的,于是产生了做“学生服务系统”想法.相信各大高校应该都有本校APP或超级课程表之类的 ...
- 一次Python爬虫的修改,抓取淘宝MM照片
这篇文章是2016-3-2写的,时隔一年了,淘宝的验证机制也有了改变.代码不一定有效,保留着作为一种代码学习. 崔大哥这有篇>>小白爬虫第一弹之抓取妹子图 不失为学python爬虫的绝佳教 ...
- python爬虫前提技术
1.BeautifulSoup 解析html如何使用 转自:http://blog.csdn.net/u013372487/article/details/51734047 #!/usr/bin/py ...
- 如何利用 Python 爬虫实现给微信群发新闻早报?(详细)
1. 场景 经常有小伙伴在交流群问我,每天的早报新闻是怎么获取的? 其实,早期使用的方案,是利用爬虫获取到一些新闻网站的标题,然后做了一些简单的数据清洗,最后利用 itchat 发送到指定的社群中. ...
- Python爬虫 小白[3天]入门笔记
笔记来源 Day-0 1.如果你还不了解Python的基础语法,可以移步|>>>Python 基础 小白 [7天] 入门笔记<<<|或自行学习. 简介 1.什么是爬 ...
- Python爬虫入门
Python爬虫简介(来源于维基百科): 网络爬虫始于一张被称作种子的统一资源地址(URLs)列表.当网络爬虫访问这些统一资源定位器时,它们会甄别出页面上所有的超链接,并将它们写入一张"待访列表",即 ...
- python爬虫抓网页的总结
python爬虫抓网页的总结 更多 python 爬虫 学用python也有3个多月了,用得最多的还是各类爬虫脚本:写过抓代理本机验证的脚本,写过在discuz论坛中自动登录自动发贴的脚本,写过自 ...
- Python爬虫(一)
花了四天的时间用python写了个简单的爬虫程序.整个过程分为两个部分:工具的安装和程序的实现 本文并没有讲程序的详细实现遇到的问题,而是对着手前一些前期的准备 第一部分(工具的安装) 开发工具的下载 ...
随机推荐
- ngx_http_upstream_keepalive
链接:http://wiki.nginx.org/HttpUpstreamKeepaliveModule 今天看了一些代码: upstream b_memc2 { server ; keepalive ...
- Hive Web Interface的安装
Hive Web Interface,简称hwi,是Hive的Web接口. 首先,安装ant,下载ant,解压,并在/etc/profile中设置: export ANT_HOME=/opt/apac ...
- Python两个变量的值进行交换的方法
Python两个变量的值进行交换的方法 使用第三方变量: '''这是第一种赋值方法,采用第三方变量''' c = a a = b b = c 使用两个变量: '''使用两个变量''' a = a+b ...
- Linux日志文件utmp、wtmp、lastlog、messages
1.有关当前登录用户的信息记录在文件utmp中:==who命令 2.登录进入和退出纪录在文件wtmp中:==w命令 3.最后一次登录文件可以用lastlog命令察看: 4.messag ...
- J2EE开发时的包命名规则,养成良好的开发习惯
代码编写规范目的:能够在编码过程中实现规范化,为以后的程序开发中养成良好的行为习惯.代码编写规范使用范围:J2EE项目开发.包命名规范:目的:包的命名规范应当体现出项目资源良好的划分 servlet类 ...
- 【AIX】查看系统内存、CPU等信息
1.查看内存大小(结果单位为kb) bootinfo –r 2.查看物理CPU个数 prtconf|grep Processors 3.查看逻辑CPU个数 pmcycles –m 4.查看COU核数 ...
- V-rep学习笔记:串口操作
VREP Regular API提供了串口操作的相关函数,可以对串口进行打开.关闭和读写: 下面使用一款淘宝上常见的AHRS(Attitude and heading reference system ...
- mysql计算时间差值,单位分钟数
TIMESTAMPDIFF(MINUTE, 开始时间, 结束时间) as 时间差(单位:分钟数) TIMESTAMPDIFF(interval,datetime_expr1,datetime_expr ...
- code vs 1013 求先序排列
2001年NOIP全国联赛普及组 题目描述 Description 给出一棵二叉树的中序与后序排列.求出它的先序排列.(约定树结点用不同的大写字母表示,长度<=8). 输入描述 Input De ...
- docker build 指定dockerfile
1. Dockerfile文件使用 docker build命令会根据Dockerfile文件及上下文构建新Docker镜像.构建上下文是指Dockerfile所在的本地路径或一个URL(Git仓库地 ...