【发布时间】:2019-09-15 20:28:30
【问题描述】:
我想从下面的 html 页面更改链接:
//html
<html>
<head>
<title>Hello</title>
</head>
<body>
<p>this is a simple text in html file</p>
<a href="https://google.com">Google</a>
<a href="/frontend/login/">Login</a>
<a href="/something/work/">Something</a>
</body>
</html>
//Result
<html>
<head>
<title>Hello</title>
</head>
<body>
<p>this is a simple text in html file</p>
<a href="https://google.com">Google</a>
<a href="/more/frontend/login/part/">Login</a>
<a href="/more/something/work/extra/">Something</a>
</body>
</html>
那么如何将 html 更改为 result 并使用 python 将其保存为 html 呢?
【问题讨论】:
-
到目前为止你尝试了什么?您可以使用 beautifulsoup 轻松解析 html 或其他抓取库。
-
此示例替换链接而不是修改链接。我想用以前的链接而不是新链接添加更多内容。
-
认为该示例使用了替换
标签: python regex python-3.x beautifulsoup