Skip to main content

EasyHTML 中文的python HTML解析提取器!

如果程序错了,请报告给534047068@qq.com。


输入首字母快速输入,不用切换输入法。按下Tab键补全。
(我用的pycharm)


# 假设有以下 HTML 代码
from Easy_HTML_2023 import EH
html = '''
<html>
<body>
    <div class="container">
        <h1>标题</h1>
        <p>段落文本</p>
        <a href="https://example.com">链接1</a>
        <a href="https://example.com">链接2</a>
    </div>
    <div class="box">
        <h2>副标题</h2>
        <p>其他文本</p>
        <a href="https://example.com">链接3</a>
    </div>
</body>
</html>
'''

# 创建美丽汤对象
soup = EH.EH(html)

# 获取所有的 div 标签内容
div内容 = soup.查找标签('div')
for 内容 in div内容:
    文本内容 = soup.获得文本(内容)
    print(文本内容)

# 获取类名为 "container" 的元素内容
container内容 = soup.查找类名('container')
for 内容 in container内容:
    文本内容 = soup.获得文本(内容)
    print(文本内容)

# 获取所有的链接及其网址
链接列表 = soup.查找链接()

运行上述代码将输出以下结果:

标题 段落文本 链接1 链接2
标题 段落文本 链接1 链接2
链接1
链接2
https://example.com
https://example.com

使用方法相当于beautifulsoup,不过也略有不同。(可以去看源代码)。

Metadata

Release files for EasyHTML2023 1.0.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for EasyHTML2023 1.0.0.1
File Size Uploaded Provenance Actions
EasyHTML2023-1.0.0.1.tar.gz 2.1 kB Without provenance Details for EasyHTML2023-1.0.0.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for EasyHTML2023 1.0.0.1
File Interpreter ABI Platform Actions
EasyHTML2023-1.0.0.1-py3-none-any.whl Python 3 none any Details for EasyHTML2023-1.0.0.1-py3-none-any.whl

Total release size: 4.7 kB

Release files / EasyHTML2023-1.0.0.1.tar.gz

Download URL EasyHTML2023-1.0.0.1.tar.gz
Size 2.1 kB
Tags Source
SHA-256 checksum
How to use checksums
2168abbafba909353bf4fdd718c95828e20f0f7cabe5ebad959e4e93733360d7
BLAKE2b-256 checksum
How to use checksums
273b702b74c998dd659594553cbb345573baca43af6fef707cbd869f1772395f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.7.6

Release files / EasyHTML2023-1.0.0.1-py3-none-any.whl

Download URL EasyHTML2023-1.0.0.1-py3-none-any.whl
Size 2.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
600ca73a5f9cb8173f50f900981e9b50ebde33b250077924749bdb87eae3a69c
BLAKE2b-256 checksum
How to use checksums
db0d554743d4b1f154017b290e3eeff8f3aa101c17ae1661ad759cfce6d83c34
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.7.6

Security for EasyHTML2023 1.0.0.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.0.0.1 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page