Two python classes that I use as a base for all my projects
python 3+
colorama
termcolor
Importing and initialising the classes
from utils import Logger, ProxyManager
logger = Logger()
proxymanager = ProxyManager()
logger.log("did something")
: produces normal output with a timestamplogger.success("did something good")
: produces green output with a timestamplogger.error("did something bad")
: produces red output with a timestamplogger.warn("did something not so good")
: produces yellow output with a timestamplogger.status("about to do something")
: produces purple output with a timestamp
The system works by returning the proxy from the top of the list and then moving it to the bottom. That way it rotates through proxies.
proxymanager.get_proxy()
Returns a proxy in the necessary format for usage in a request
import requests
from utils import Logger, ProxyManager
logger = Logger()
proxymanager = ProxyManager()
logger.log("Sending http request")
r = requests.get('https://example.org', proxy=proxymanager.get_proxy())
if r.status_code == 200:
logger.success("OK response received")
else:
logger.error("Something bad happened")
You shouldn't need it.