不存储cookies

2024-09-21 03:22:52 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在尝试自动化一个我想在pokemon vortex中获得成功的游戏,当我使用selenium登录时,它工作得很好,但是当我尝试加载一个需要用户登录的页面时,我会被直接发送回登录页面(我在selenium之外使用同一个浏览器chrome进行了尝试)。你知道吗

这就是我所拥有的

import time
from selenium import webdriver
from random import randint




driver = webdriver.Chrome(r'C:\Program Files (x86)\SeleniumDrivers\chromedriver.exe')  
driver.get('https://zeta.pokemon-vortex.com/dashboard/');
time.sleep(5) # Let the user actually see something!

usernameLoc = driver.find_element_by_id('myusername')
passwordLoc = driver.find_element_by_id('mypassword')

usernameLoc.send_keys('mypassword')
passwordLoc.send_keys('12345')

submitButton = driver.find_element_by_id('submit')
submitButton.submit()

time.sleep(3)

driver.get('https://zeta.pokemon-vortex.com/map/10')
time.sleep(10)

我使用的是python3.6+,我今天刚刚安装了selenium,所以它是最新的,如何强制selenium保留cookies?你知道吗


Tags: fromimportidgetbytimedriverselenium

热门问题