from selenium.webdriver import ActionChains
from pynput.keyboard import Key, Controller as c2
from pynput.mouse import Button, Controller as c1
from selenium import webdriver
import time
key=c2()
mouse = c1()
options = webdriver.ChromeOptions()
options.add_experimental_option('excludeSwitches', ['enable-automation'])#开发者模式,
driver = webdriver.Chrome(executable_path=r'D:\爬虫相关\资料\驱动程序\chromedriver_win32\chromedriver.exe',chrome_options=options)
driver.maximize_window()
js = 'window.open("https://magi.com");'
driver.execute_script(js)
windows = driver.window_handles
driver.switch_to.window(windows[-1])
time.sleep(2)
mouse.position = (500, 320)
mouse.press(Button.left)
mouse.release(Button.left)
time.sleep(1)
key.type('金融')
time.sleep(0.5)
mouse.position = (720, 110)
mouse.press(Button.left)
mouse.release(Button.left)
time.sleep(5)
mouse.position = (890, 330)
mouse.press(Button.left)
mouse.move(1150, 330)
mouse.release(Button.left)
time.sleep(5)
cookies_dic={}
for coo in driver.get_cookies():
cookies_dic[coo["name"]] = coo["value"]
print(cookies_dic)
driver.quit()