Skip to content

Instantly share code, notes, and snippets.

View vertigg's full-sized avatar
🥚

Serhii Salnikov vertigg

🥚
View GitHub Profile
#
# Example of automatical rotating proxy middleware for scrapy-rotating-proxies using proxybroker
#
import codecs
import logging
from subprocess import call
from rotating_proxies.expire import Proxies
from rotating_proxies.middlewares import RotatingProxyMiddleware
@vertigg
vertigg / example.py
Last active January 17, 2023 07:29
Starlette class-based PubSub Websocket Endpoint
"""
Heavily inspired by https://gist.github.com/timhughes/313c89a0d587a25506e204573c8017e4
This is an example of class-based WebSocketEndpoint.
To use - just subclass your endpoint with RedisPubSubWebSocketEndpoint and use it as is.
You can also override on_connect, on_disconnect, on_receive and new on_published_message methods
New internal method "publish" acts like "broadcast" for any subscribed websocket
"""
import json