转换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

相关推荐
平生不喜凡桃李6 分钟前
浅谈 Linux 中 namespace 相关系统调用
java·linux·服务器
zb2006412012 分钟前
CVE-2024-38819:Spring 框架路径遍历 PoC 漏洞复现
java·后端·spring
2401_8955213421 分钟前
spring-ai 下载不了依赖spring-ai-openai-spring-boot-starter
java·人工智能·spring
何仙鸟1 小时前
GarmageSet下载和处理
java·开发语言
wefly20171 小时前
免安装!m3u8live.cn在线 M3U8 播放器,小白也能快速上手
java·开发语言·python·json·php·m3u8·m3u8在线转换
yuweiade1 小时前
springboot和springframework版本依赖关系
java·spring boot·后端
ywf12151 小时前
springboot设置多环境配置文件
java·spring boot·后端
爱学习的程序媛1 小时前
【Web前端】JavaScript设计模式全解析
前端·javascript·设计模式·web
小马爱打代码1 小时前
SpringBoot + 消息生产链路追踪 + 耗时分析:从创建到发送,全链路性能可视化
java·spring boot·后端
小码哥_常1 小时前
从SharedPreferences到DataStore:Android存储进化之路
前端