34 lines
1.4 KiB
Python
34 lines
1.4 KiB
Python
import time, requests, os
|
|
from selenium import webdriver #Webdriver de Selenium qui permet de contrôler un navigateur
|
|
from webdriver_manager.chrome import ChromeDriverManager #Assure la gestion du webdriver de Chrome
|
|
from selenium.webdriver.chrome.options import Options
|
|
|
|
from selenium.webdriver.common.keys import Keys
|
|
from selenium.webdriver.common.by import By
|
|
from selenium.webdriver.common.action_chains import ActionChains
|
|
|
|
chrome_options = Options()
|
|
#chrome_options.add_argument("--headless=new") # for Chrome >= 109
|
|
browser = webdriver.Chrome() #Initialisation du driver
|
|
browser.get("https://fetlife.com/login")
|
|
user_agent = browser.execute_script("return navigator.userAgent;")
|
|
time.sleep(1)
|
|
print("user-agent : {0}".format(user_agent))
|
|
print("authencity_token : {0}".format(browser.find_element(By.NAME, "authenticity_token").get_attribute("value")))
|
|
authencity_token=browser.find_element(By.NAME, "authenticity_token").get_attribute("value")
|
|
cookie = ["_cfuvid", "__cf_bm", "_fl_sessionid", "cf_clearance", "fetlife_pwa", "language"]
|
|
cookies = {}
|
|
for i in cookie:
|
|
if browser.get_cookie(i) is not None:
|
|
print("{0}: {1}".format(i, browser.get_cookie(i)["value"]))
|
|
cookies[i]=browser.get_cookie(i)["value"]
|
|
|
|
user_id = browser.find_element(By.ID, "user_login")
|
|
|
|
user_id.send_keys(os.environ["USER"])
|
|
|
|
password = browser.find_element(By.ID, "user_password")
|
|
password.send_keys(os.environ["PASSWORD"])
|
|
|
|
browser.quit()
|