Jas*_*Tan 14
Perl(一如既往)是您的朋友。我认为这会做到:
perl -n -mHTML::Entities -e ' ; print HTML::Entities::decode_entities($_) ;'
Run Code Online (Sandbox Code Playgroud)
例如:
echo '"test" & test $test ! test @ # $ % ^ & *' |perl -n -mHTML::Entities -e ' ; print HTML::Entities::decode_entities($_) ;'
Run Code Online (Sandbox Code Playgroud)
有输出:
someguy@somehost ~]$ echo '"test" & test $test ! test @ # $ % ^ & *' |perl -n -mHTML::Entities -e ' ; print HTML::Entities::decode_entities($_) ;'
"test" & test $test ! test @ # $ % ^ & *
Run Code Online (Sandbox Code Playgroud)
PHP 非常适合这一点。此示例需要 PHP 5:
cat file.html | php -R 'echo html_entity_decode($argn);'
Run Code Online (Sandbox Code Playgroud)
recode似乎在主要 GNU/Linux 发行版的默认软件包存储库中可用。例如将 HTML 实体解码为 UTF-8 :
…|recode html..utf8
Run Code Online (Sandbox Code Playgroud)
小智 5
使用 Python 3:
python3 -c 'import html,sys; print(html.unescape(sys.stdin.read()), end="")' < file.html
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
12018 次 |
| 最近记录: |