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和Javac的使用时总提示找不到类模块的解决方案
1.场景: 争对网上的很多文章中javac编译与java运行的文章,有很多不明确的地方,使得在合适时发现很多坑.这里给大家作下简介. 2.Javac的使用注意: javac -d ./ ./Insta ...
- 如何导入外部Git仓库到中国源代码托管平台(Git@OSC)
git clone --bare http://git.rcrtm.com/git/dianli.git git clone --mirror https://git.oschina.net/cand ...
- server.xml引入子文件配置(tomcat虚拟主机)[转]
在配置tomcat虚拟主机时候,如何每一个虚拟主机写成单独文件,server.xml包含这些子文件? 如以下<OneinStack>中,添加JAVA环境虚拟主机后tomcat配置文件详情: ...
- 一个简单的C/S事例——JAVA-Socket
TalkClient.java import java.io.*; import java.net.*; public class TalkClient { public static void ma ...
- MySQL auto_increment初始值设置
http://blog.csdn.net/u011439289/article/details/48055917 DROP TABLE IF EXISTS zan1; CREATE TABLE zan ...
- Android 百度地图开发(一)
在自己的Android项目中增加百度地图的功能. 一 申请API key 在使用百度地图之前,我们必须去申请一个百度地图的API key,申请地址http://lbsyun.baidu.com/api ...
- 查询后n条记录
查询后n条记录 SELECT * FROM tb_stu ORDER BY id ASC LIMIT n
- python 模块之os.path模块
# -*- coding: cp936 -*- #python 27 #xiaodeng #python 模块之os.path模块 #http://www.cnblogs.com/dkblog/arc ...
- PHP 反射 初步测试
<?php //php反射机制 /* //用途 1 该扩展分析php程序,导出或提取出关于类,方法,属性,参数等详细信息,包括注释 //Reflection可以说是对php库函数: /class ...
- ArcGIS10.1正式版全套下载、安装与破解(附ArcGIS10.1全套下载地址)【转】
一.准备文件1.ArcGIS10.1安装包:ArcGIS_Desktop_10.1_129026(en)2.认证服务:Pre-release_license_manager3.注册机:arcgis10 ...