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写了个简单的爬虫程序.整个过程分为两个部分:工具的安装和程序的实现 本文并没有讲程序的详细实现遇到的问题,而是对着手前一些前期的准备 第一部分(工具的安装) 开发工具的下载 ...
随机推荐
- JAVA GC优化入门
为什么需要优化GC? JAVA的GC是面试必考的题目,可是在实际项目中什么时候使用GC哪?或者应该什么时候优化GC哪?有句名言:“GC优化永远是最后一项任务”. 在使用GC之前,应该考虑一下进行GC的 ...
- top命令参数
参数说明 d 指定每两次屏幕信息刷新之间的时间间隔.当然用户可以使用s交互命令来改变之. p 通过指定监控进程ID来仅仅监控某个进程的状态. q该选项将使top没有任何延迟的进行刷新.如果调用程序有超 ...
- ES6学习笔记三:Symbol、Set、Map
一:Symbol ES6 引入了一种新的原始数据类型Symbol,表示独一无二的值.它是 JavaScript 语言的第七种数据类型,前六种是:undefined.null.布尔值(Boolean). ...
- Java之创建对象>5.Avoid creating unnecessary objects
String s = new String("stringette"); // DON'T DO THIS! The improved version is simply the ...
- java 浮点运算
CreateTime--2017年12月1日11:35:00 Author:Marydon java 浮点类型(float.double)间的运算工具类 /** * 进行BigDecimal对象的 ...
- django之创建第4-1个项目-访问dict数据
1.修改index.html文件 <!DOCTYPE html> <html lang="en"> <head> <meta charse ...
- Javascript Get or Set Checked Radio Value
Description This pair of Javascript function can get or set the checked value of a group of radio bu ...
- PHP 反射 初步测试
<?php //php反射机制 /* //用途 1 该扩展分析php程序,导出或提取出关于类,方法,属性,参数等详细信息,包括注释 //Reflection可以说是对php库函数: /class ...
- 自己使用过比较好用的VSCode插件
C/C++ [ms-vscode.cpptolls] 智能推导,调试和代码浏览 C/C++ Clang Command Adapter [mitaki28.vscode-clang] 使用 ...
- adjustResize和adjustPan的比较
在下面的描述中,编辑框的maxLine都设定为10. 在信息列表界面中,编辑框在RelativeLayout中定义.编辑框上边(above)的列表组件的高度不会缩小为0,导致显示出现一点问题. 当信息 ...