from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
import pickle
import time
# Specify the path to the ChromeDriver executable
chrome_driver_path = '/Users/jitendersingh/Documents/chromedriver' # Change this to the actual path
service = Service(chrome_driver_path)
driver = webdriver.Chrome(service=service)
# Open the login page
driver.get('https://www.instagram.com/login')
# Use WebDriverWait to wait until the login form is visible (adjust timeout as needed)
wait = WebDriverWait(driver, 60)
dashboard_element = wait.until(EC.presence_of_element_located((By.XPATH, '/html/body/div[1]/div/div[2]/div[2]/div[2]/div/div/div[2]/div/div[1]/div/div[1]/div/span')))
cookies = driver.get_cookies()
with open("/Users/jitendersingh/Documents/instaookies.pkl", "wb") as pkl_file:
pickle.dump(cookies, pkl_file)
# Close the browser
driver.quit()
0 comments:
Post a Comment