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 zxing生成二维码
package zxing.test; import com.google.zxing.BarcodeFormat; import com.google.zxing.EncodeHintType; i ...
- Tomcat访问日志浅析 (转)
来自:http://blog.chinaunix.net/uid-20691565-id-3938220.html Tomcat的访问日志是靠org.apache.catalina.valves.Ac ...
- SSM实战——秒杀系统之Web层Restful url设计、SpringMVC整合、页面设计
一:Spring整合SpringMVC 1:编写web.xml,配置DispatcherServlet <web-app xmlns="http://java.sun.com/xml/ ...
- Maven依赖传递、依赖传递排除、依赖冲突
转载请注明原文地址:http://www.cnblogs.com/ygj0930/p/6628429.html 一:Maven依赖传递 假如有Maven项目A,项目B依赖A,项目C依赖B.那么我们可 ...
- Laravel中pluck的使用——返回指定的字段值信息列表
$model = self::where(['is_delete' => 0, 'is_on_sale' => 1]) ->whereIn('goods.cat_id', Goods ...
- 〖Android〗dropbear一些操作命令备忘
相关命令行: # 启动dropbear后台运行 /data/local/tmp/dropbear \ -A -N android -I -C -G -p \ -R /data/local/tmp/au ...
- 〖Linux〗gun screen 配置文件
screen 默认使用 bash shell,一般情况下screen只用于android build,tmux则是我的日常使用多终端管理工具. # Default Shell shell " ...
- OpenCV学习代码记录——轮廓(contour)检测
很久之前学习过一段时间的OpenCV,当时没有做什么笔记,但是代码都还在,这里把它贴出来做个记录. 代码放在码云上,地址在这里https://gitee.com/solym/OpenCVTest/tr ...
- 给X240换上了三键触摸板
X240自带的触摸板非常不好用, 对于我这样的指点杆重度用户, 每次要按下整块板真的是太费力了, 而且在夜里声音很吵. 在淘宝上买了三键的X250的触摸板换上了. 这是购买的触摸板的型号 换的时候, ...
- 使用maven-assembly-plugin打包zipproject
使用Maven对Web项目进行打包.默觉得war包.但有些时候.总是希望打成zip包(亦或其它压缩包,类似tomcat的那种文件夹结构,直接运行bin/startup.sh就能够),maven-war ...