From aeae6023447b55ccf99e19c173dcb0563e17ff3f Mon Sep 17 00:00:00 2001 From: Bla Date: Thu, 12 Oct 2023 14:56:30 +0000 Subject: [PATCH] alles --- Dockerfile | 14 ++++++++++++++ docker-compose.yml | 9 +++++++++ server.py | 43 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 66 insertions(+) create mode 100644 Dockerfile create mode 100644 docker-compose.yml create mode 100644 server.py diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..3af2560 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,14 @@ +FROM python:3.10 + +RUN pip install --no-cache-dir --upgrade pip && \ + pip install --no-cache-dir selenium-wire + +RUN apt-get update && apt-get -y install chromium + +RUN mkdir /app + +WORKDIR /app + +ENV PYTHONUNBUFFERED=1 + +CMD ["python", "server.py"] diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..74af0e8 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,9 @@ +version: "2" + +services: + server: + build: . + restart: always + mem_limit: 1024m + volumes: + - ./server.py:/app/server.py diff --git a/server.py b/server.py new file mode 100644 index 0000000..81faf0c --- /dev/null +++ b/server.py @@ -0,0 +1,43 @@ +from seleniumwire import webdriver # Import from seleniumwire +from seleniumwire.utils import decode +from time import sleep +import json +import re + +options = webdriver.ChromeOptions() +options.add_argument('--headless') +options.add_argument("--incognito") +options.add_argument("--nogpu") +options.add_argument("--disable-gpu") +options.add_argument("--window-size=1280,1280") +options.add_argument("--no-sandbox") +options.add_argument("--enable-javascript") +options.add_argument('--disable-dev-shm-usage') + +# Create a new instance of the Chrome driver +driver = webdriver.Chrome(options=options) + + +def interceptor(request, response): # A response interceptor takes two args + if 'ws-travis.dus.com/socket.io/' in request.url : + body = decode(response.body, response.headers.get('Content-Encoding', 'identity')) + x = re.split("\d\d\d:\d\d\/dus,", body.decode("utf-8")) + if len(x) > 1: + for i in [i for i in x if i]: + j = json.loads(i) + print (j) + else: + j = json.loads(x) + print (j) + #offset = str(body).find('[') + #print ("\n" , str(body)[offset:] , "\n") + #j = json.loads(body[offset:]) + #print (x) + +driver.response_interceptor = interceptor + +# Go to the Google home page +driver.get('https://dus-travis.dus.com/') + +sleep(1000) +