用于python的sse客户端

sseclient-p的Python项目详细描述


用于python的服务器端事件(sse)客户端

一个用于sse事件源的python客户机,它与 urllib3requests

安装

$ pip install sseclient-py

使用量

importjsonimportpprintimportsseclientdefwith_urllib3(url):"""Get a streaming response for the given event feed using urllib3."""importurllib3http=urllib3.PoolManager()returnhttp.request('GET',url,preload_content=False)defwith_requests(url):"""Get a streaming response for the given event feed using requests."""importrequestsreturnrequests.get(url,stream=True)url='http://domain.com/events'response=with_urllib3(url)# or with_requests(url)client=sseclient.SSEClient(response)foreventinclient.events():pprint.pprint(json.loads(event.data))

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
JAXB可以将ArrayList作为逗号分隔的值输出吗?   java使用bcel将一个内部类移动到另一个外部类   java无法识别Lucene MoreLikeThis中的错误   安卓如何在Frida中将动态类转换为json或java文件   java如何使用Struts2在blob类型的列中保存我的sql中的图像?   使用mavenreleaseplugin将java maven发布到nexus 3.0.1失败   java这是正确的方法吗?   Windows上的java Runner不工作   找不到java Hibernate+Spring xml映射   java如何访问WMI查询的数据(通过JNA)SAFEARRAY结果   java如何在本地导入库而不使用Maven中的Nexus?   java渐变本地项目依赖项   使用URLFetchService/URL Google appengine for java