转换html特殊符号

import html

import re

def replace_html(src_src):

replace_str=str.replace(src_src," "," ")

replace_str=str.replace(replace_str,"&lt;",'<')

replace_str=str.replace(replace_str,"&gt;",'>')

replace_str=str.replace(replace_str,"&amp;",'&')

replace_str=str.replace(replace_str,"&quot;",'"')

replace_str=str.replace(replace_str,"'","'")

replace_str=str.replace(replace_str,"&cent;",'¢')

replace_str=str.replace(replace_str,"&pound;",'£')

replace_str=str.replace(replace_str,"&yen;",'¥')

replace_str=str.replace(replace_str,"&euro;",'€')

replace_str=str.replace(replace_str,"&sect;",'§')

replace_str=str.replace(replace_str,"&copy;",'©')

replace_str=str.replace(replace_str,"&reg;",'®')

replace_str=str.replace(replace_str,"&trade;;",'™')

replace_str=str.replace(replace_str,"&times;",'×')

replace_str=str.replace(replace_str,"&divide;",'÷')

replace_str=str(html.unescape(src_src))

#replace_str=replace_str.replace(' ','{|}').replace(' ','{|}').replace('、','{|}')

replace_str=re.sub('[\s\u3002|\uff1f|\uff01|\uff0c|\u3001|\uff1b|\uff1a|\u201c|\u201d|\u2018|\u2019|\uff08|\uff09|\u300a|\u300b|\u3010|\u3011|\u007e]+','{|}',replace_str)

replace_str=re.sub('^\{\|\}','',replace_str)

replace_str=re.sub('\{\|\}$','',replace_str)

return replace_str

相关推荐
rit8432499几秒前
C# Socket 聊天室(含文件传输)
服务器·开发语言·c#
GIS之路8 分钟前
使用命令行工具 ogr2ogr 将 CSV 转换为 Shp 数据(二)
前端
kk哥889917 分钟前
C++ 对象 核心介绍
java·jvm·c++
嘉琪00121 分钟前
Vue3+JS 高级前端面试题
开发语言·前端·javascript
招风的黑耳27 分钟前
我用SpringBoot撸了一个智慧水务监控平台
java·spring boot·后端
xunyan623428 分钟前
面向对象(下)-接口的理解
java·开发语言
程序员游老板31 分钟前
基于SpringBoot3+vue3的爱心陪诊平台
java·spring boot·毕业设计·软件工程·课程设计·信息与通信
期待のcode34 分钟前
Springboot核心构建插件
java·spring boot·后端
遥不可及~~斌36 分钟前
Java 面试题集 -- 001
java·开发语言
hkhkhkhkh1231 小时前
Linux设备节点基础知识
linux·服务器·驱动开发