小编use*_*267的帖子

使用perl剥离除html标记之外的所有内容

我一直在寻找一种方法来从html文档中删除所有内容,只留下html标记.有人知道这个方法吗?我有很多perl模块的经验,并且已经彻底搜索过这个网站.

我想将html作为字符串传递给我的perl脚本并删除除标签之外的所有内容.这是一个例子:

传入:

<!doctype html>
<html>
<head>
<title>Example Domain</title>

<meta charset="utf-8" />
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<style type="text/css">
body {
    background-color: #f0f0f2;
    margin: 0;
    padding: 0;
    font-family: "Open Sans", "Helvetica Neue", Helvetica, Arial, sans-serif;

}
div {
    width: 600px;
    margin: 5em auto;
    padding: 50px;
    background-color: #fff;
    border-radius: 1em;
}
a:link, a:visited {
    color: #38488f;
    text-decoration: none;
}
@media (max-width: 700px) {
    body {
        background-color: #fff;
    }
    div {
        width: auto;
        margin: 0 auto;
        border-radius: …
Run Code Online (Sandbox Code Playgroud)

html regex perl

6
推荐指数
1
解决办法
317
查看次数

标签 统计

html ×1

perl ×1

regex ×1