This commit is contained in:
Yeet 2024-09-24 21:38:29 +02:00
parent c851b9d7e2
commit d63a39b49a
3 changed files with 15 additions and 4 deletions

View File

@ -16,10 +16,10 @@ RUN apt-get update && \
wget \
curl \
unzip \
chromium-driver \
build-essential \
libsqlite3-dev \
sqlite3 \
chromium \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
@ -27,10 +27,11 @@ RUN apt-get update && \
RUN pip install --no-cache-dir -r requirements.txt
# Set up Chrome WebDriver for Selenium
RUN wget -q -O /app/chromedriver.zip https://chromedriver.storage.googleapis.com/114.0.5735.90/chromedriver_linux64.zip && \
RUN wget -q -O /app/chromedriver.zip https://storage.googleapis.com/chrome-for-testing-public/129.0.6668.70/linux64/chromedriver-linux64.zip && \
unzip /app/chromedriver.zip && \
mv /app/chromedriver-linux64/chromedriver /app && \
chmod +x /app/chromedriver && \
rm /app/chromedriver.zip
rm -rf /app/chromedriver.zip /app/chromedriver-linux64
# Set environment variables for Chrome and ChromeDriver
ENV PATH=/app:$PATH

View File

@ -8,3 +8,4 @@ google-auth==2.34.0
google-auth-httplib2==0.2.0
google-auth-oauthlib==1.2.1
googleapis-common-protos==1.65.0
webdriver-manager==4.0.2

View File

@ -8,6 +8,10 @@ import time
import requests
import config
from selenium.webdriver.chrome.service import Service
from webdriver_manager.chrome import ChromeDriverManager
service = Service(ChromeDriverManager().install())
class XClient:
@ -28,16 +32,19 @@ class XClient:
def fetch_access_token(self):
# Set up the WebDriver (make sure to use the correct path for your WebDriver)
print("starting chromedriver")
options = webdriver.ChromeOptions()
options.add_argument("--headless=new")
options.add_argument("--no-sandbox")
service = Service(executable_path=config.CHROMEDRIVER_PATH)
print("started chromedriver")
driver = webdriver.Chrome(options=options, service=service)
driver.get("https://x.tudelft.nl")
print("Check1")
button = WebDriverWait(driver, 30).until(
EC.element_to_be_clickable(
(By.XPATH, "//span[contains(text(), 'TUDelft')]")
@ -53,6 +60,8 @@ class XClient:
)
)
)
print("Check2")
button.click()
# Input the username