-
python入门教程之python去除html标签
本站最新发布 Python从入门到精通|Python基础教程
试听地址 https://www.xin3721.com/eschool/pythonxin3721/
试听地址 https://www.xin3721.com/eschool/pythonxin3721/
python去除html标签,自己写的,若有不足请指正:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
#! /usr/bin/env python #coding=utf- 8 # blueel 2013 - 01 - 19 from HTMLParser import HTMLParser class MLStripper(HTMLParser): def __init__(self): self.reset() self.fed = [] def handle_data(self, d): self.fed.append(d) def get_data(self): return '' .join(self.fed) def strip_tags(html): s = MLStripper() s.feed(html) return s.get_data() |
调用:
html = '<em productIndex="0" class="valor-dividido" style="display:block"><span>ou <strong><label productIndex="0" class="skuBestInstallmentNumber">12</label>X</strong> de <strong> <label productIndex="0" class="skuBestInstallmentValue">R$ 116,58</label></strong> sem juros</span></em>'
print strip_tags(html)
最新更新
python去除html标签
Python中Queue模块及多线程使用
多线程下每个线程的执行方式
如何写出高质量的代码之数组优化
Python多线程进程和线程的区别5
Python多线程进程和线程的区别4
Python多线程进程和线程的区别3
Python多线程进程和线程的区别2
Python多线程进程和线程的区别
Python迭代器和生成器
.Net Standard(.Net Core)实现获取配置信息
Linux PXE + Kickstart 自动装机
Shell 编程 基础
Shell 编程 条件语句
CentOS8-网卡配置及详解
Linux中LVM逻辑卷管理
1.数码相框-相框框架分析(1)
Ubuntu armhf 版本国内源
Linux中raid磁盘阵列
搭建简易网站
access教程之Access简介
mysql 安装了最新版本8.x版本后的报错:
Mysql空间数据&空间索引(spatial)
如何远程连接SQL Server数据库的图文教程
复制SqlServer数据库的方法
搜索sql语句
sql中返回参数的值
sql中生成查询的模糊匹配字符串
数据定义功能
数据操作功能