Skip to main content

observer-ward-py

Python绑定库,用于web技术指纹识别。这是ObserverWard项目中observer-ward库的Python接口。

安装

用法

基本用法

import os
from observer_ward import ObserverWard

with open('examples/test_fingerprints.json', 'r') as f:
    content = f.read()

# 初始化ObserverWard对象
# 不提供参数时,会尝试从默认位置加载指纹库
observer_ward = ObserverWard(content)

# 从HTML内容识别web技术
html_content = """
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="generator" content="WordPress 5.8.2">
    <title>示例网页</title>
</head>
<body>
    <div class="container">
        <h1>Hello World</h1>
    </div>
</body>
</html>
"""

# 提供HTTP头 (可选)
headers = [
    ("Server", "nginx/1.18.0"),
    ("X-Powered-By", "PHP/7.4.0")
]

# 执行指纹识别
results = observer_ward.execute(html_content, headers)

# 打印匹配结果
for result in results:
    print(f"名称: {result['name']}")
    print(f"模板: {result['template']}")
    print(f"标签: {', '.join(result['tags'])}")
    print(f"匹配关键词: {', '.join(result['matcher_names'])}")
    
    if result['extractor']:
        print("提取数据:")
        for key, values in result['extractor'].items():
            print(f"  {key}: {values}")
    
    print("-" * 40)

使用自定义指纹库

from observer_ward import ObserverWard
import json

# 读取自定义指纹库
with open("my_fingerprints.json", "r") as f:
    json_content = f.read()

# 使用自定义指纹库初始化ObserverWard
observer_ward = ObserverWard(json_content)

# 执行指纹识别
results = observer_ward.execute(html_content, headers)

# 打印结果
print(f"找到 {len(results)} 个匹配结果")
for result in results:
    print(f"名称: {result['name']}")
    # ...其他处理代码

构建开发版本

cd python
maturin develop

Metadata

Release files for observer-ward 0.1.0

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

Source distribution (sdist)

Source distribution for observer-ward 0.1.0
File Size Uploaded
observer_ward-0.1.0.tar.gz 86.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for observer-ward 0.1.0
File Interpreter ABI Platform
observer_ward-0.1.0-cp313-cp313-manylinux_2_34_x86_64.whl CPython 3.13 CPython 3.13 Linux glibc 2.34+ x86-64 Details

Total release size: 1.1 MB

Release files / observer_ward-0.1.0.tar.gz

Download URL observer_ward-0.1.0.tar.gz
Size 86.9 kB
Tags Source
SHA-256 checksum
How to use checksums
cf0f917d40f6ecef2ad26524a75d010b60ee62358bea8696c6ce755b3da8cb61
BLAKE2b-256 checksum
How to use checksums
d7979adf02e0613214d4127e790ab22f8c66e52118dee0ad8094d20c9d7ce1b2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.10.1

Release files / observer_ward-0.1.0-cp313-cp313-manylinux_2_34_x86_64.whl

Download URL observer_ward-0.1.0-cp313-cp313-manylinux_2_34_x86_64.whl
Size 1.0 MB
Tags CPython 3.13 Linux glibc 2.34+ x86-64
SHA-256 checksum
How to use checksums
a231bc50d7d8579f34cf81beb85daa11d5db404e5d1438f838e2afdaba16761a
BLAKE2b-256 checksum
How to use checksums
0d125d5a9d605fa1bfbdd9bbdc6c5743d8eba5de16cdd58a4ad47d4ea694aef6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.10.1

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

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