Skip to content

Leverage selenium stealth package #5

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
secret/
output/coxusage.json
output/
.env/
10 changes: 4 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
FROM python:3.8-alpine3.10

# update apk repo
RUN echo "http://dl-4.alpinelinux.org/alpine/v3.10/main" >> /etc/apk/repositories && \
echo "http://dl-4.alpinelinux.org/alpine/v3.10/community" >> /etc/apk/repositories
FROM python:3.8-alpine

# install chromedriver
RUN apk update
RUN apk update
RUN apk add python3-dev gcc libc-dev libffi-dev
RUN apk add chromium chromium-chromedriver

# upgrade pip
RUN pip install --upgrade pip

# install selenium
RUN pip install selenium
RUN pip install selenium-stealth

COPY coxusage.py /usr/bin/coxusage.py

Expand Down
22 changes: 19 additions & 3 deletions coxusage.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium_stealth import stealth

import json
import datetime
import calendar
Expand All @@ -20,23 +22,36 @@
chrome_options.add_argument('--window-size=1420,1080')
chrome_options.add_argument('--headless')
chrome_options.add_argument('--disable-gpu')

print("[+] Starting Chrome")
driver = webdriver.Chrome(options=chrome_options)

print("[+] Setting Stealth")
# Selenium Stealth settings
stealth(driver,
languages=["en-US", "en"],
vendor="Google Inc.",
platform="Win32",
webgl_vendor="Intel Inc.",
renderer="Intel Iris OpenGL Engine",
fix_hairline=True,
)

print("[+] Getting Login page")
driver.get('https://www.cox.com/content/dam/cox/okta/signin.html')
print("[+] Waiting for fields to load")

username = WebDriverWait(driver, 60).until(EC.visibility_of_element_located((By.ID, 'okta-signin-username')))
password = driver.find_element_by_id("okta-signin-password")
password = driver.find_element(By.ID, "okta-signin-password")

username.send_keys(cox_user)
password.send_keys(cox_pass)
print("[+] Submitting Login")
driver.find_element_by_id("okta-signin-submit").click()
driver.find_element(By.ID, "okta-signin-submit").click()
print("[+] Waiting for login to complete")
time.sleep(5)
print("[+] Loading Usage")
driver.get('https://www.cox.com/internet/mydatausage.cox')
driver.get('https://www.cox.com/internettools/data-usage.html')

time.sleep(5)
print("[+] Extracting Json")
Expand All @@ -48,3 +63,4 @@

with open(json_file, 'w+') as outfile:
json.dump(data, outfile, sort_keys=True)