Selenium-Script / app.py
Container's picture
Update app.py
ca11d6d verified
raw
history blame
992 Bytes
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
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.common.exceptions import WebDriverException, TimeoutException
from fastapi import FastAPI, Request
import uvicorn
import time
app = FastAPI()
@app.get("/")
def main():
options = Options()
options.add_argument('--headless')
driver = webdriver.Chrome(options=options)
driver.get('https://test5.container-z.art/test26')
# WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.TAG_NAME, "body")))
time.sleep(10)
cookies = driver.get_cookies()
print(cookies)
current_url = driver.current_url
print(current_url)
driver.quit()
return {"code": 200,"msg":"Success"}
if __name__ == '__main__':
uvicorn.run(app='app:app', host="0.0.0.0", port=7860)