使用 Python 发现 Web 服务

发布于 2024-08-25 10:54:54 字数 200 浏览 5 评论 0原文

我的网络上有多个设备。我正在尝试使用一个库来使用 Python 脚本发现这些设备的存在和实体,这些设备都有一个 Web 服务。我的问题是,有没有任何模块可以帮助我解决这个问题,因为我找到的唯一模块是Python的ws-discovery?

如果这是唯一的模块,是否有人有任何使用 ws-discovery 的示例 Python 脚本?

感谢您的任何帮助。

I have several devices on a network. I am trying to use a library to discover the presence and itentity of these devices using Python script, the devices all have a web service. My question is, are there any modules that would help me with this problem as the only module I have found is ws-discovery for Python?

And if this is the only module does anyone have any example Python script using ws-discovery?

Thanks for any help.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

伴梦长久 2024-09-01 10:54:54

不幸的是,我自己从未使用过 ws-discovery,但似乎有一个 Python 项目实现了它:
https://pypi.org/project/WSDiscovery/

从他们的文档中,这里有一个关于如何进行操作的简短示例使用它:

wsd = WSDiscovery()
wsd.start()

ttype = QName("abc", "def")

ttype1 = QName("namespace", "myTestService")
scope1 = Scope("http://myscope")
ttype2 = QName("namespace", "myOtherTestService_type1")
scope2 = Scope("http://other_scope")

xAddr = "localhost:8080/abc"
wsd.publishService(types=[ttype], scopes=[scope2], xAddrs=[xAddr])

ret = wsd.searchServices()

for service in ret:
    print service.getEPR() + ":" + service.getXAddrs()[0]

wsd.stop()

Unfortunately I've never used ws-discovery myself, but there seems to be a Python project which implements it:
https://pypi.org/project/WSDiscovery/

From their documentation here's a short example on how to use it:

wsd = WSDiscovery()
wsd.start()

ttype = QName("abc", "def")

ttype1 = QName("namespace", "myTestService")
scope1 = Scope("http://myscope")
ttype2 = QName("namespace", "myOtherTestService_type1")
scope2 = Scope("http://other_scope")

xAddr = "localhost:8080/abc"
wsd.publishService(types=[ttype], scopes=[scope2], xAddrs=[xAddr])

ret = wsd.searchServices()

for service in ret:
    print service.getEPR() + ":" + service.getXAddrs()[0]

wsd.stop()
夜无邪 2024-09-01 10:54:54

您与 ws-discovery 有联系吗?如果没有,您可能需要考虑 Bonjour 协议,又名 ZeroConf 和 DNS-SD。该协议的实施相对广泛。我从未使用过 python 来做广告或发现,但有一个实现 API 的项目: http ://code.google.com/p/pybonjour/

正如我所说,我对这个项目没有直接的经验,只是指出它作为 ws-discovery 的替代方案。

Are you tied to ws-discovery? If not, you might want to consider the Bonjour protocol, aka ZeroConf and DNS-SD. The protocol is relatively widely implemented. I've never used python to do the advertising or discovery but there is a project that implements an API: http://code.google.com/p/pybonjour/

As I said, I have no direct experience with this project and merely point it out as an alternative to ws-discovery.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文