http://wuxia.qq.com/cp/a20160... 天涯明月刀的网站,想自动领取奖励,登陆这块就遇到问题
打开网站后,点击登陆,切换到 loginIframe 登陆 frame 输入用户名密码正确,但是登陆后无法控制验证码所在的 frame ,看不出名字,没法切换也就无法控制
代码如下:
tyurl = "http://wuxia.qq.com/cp/a20160920tmfl/" username = "123456" pwd = "1234561" binary = FirefoxBinary("z:\firefox\firefox.exe") driver = webdriver.Firefox(firefox_binary=binary,executable_path = "z:geckodrivegeckodriver.exe") driver.get(tyurl) driver.find_element_by_id("dologin").click() driver.switch_to_frame("loginIframe") # 等待账号密码登录窗口出现,点击账号密码登 WebDriverWait(driver, 10,1).until(EC.presence_of_element_located((By.ID,"switcher_plogin"))) driver.find_element_by_id("switcher_plogin").click() # 输入账号密码 WebDriverWait(driver, 30,1).until(EC.presence_of_element_located((By.ID,"login_button"))) for i in range(1,20): try: driver.find_element_by_id("u").click() driver.find_element_by_id("u").send_keys(username) driver.find_element_by_id("p").click() driver.find_element_by_id("p").send_keys(pwd) break except Exception, e: pass # 输入密码点击确定后无法定位验证码窗口 try: WebDriverWait(driver, 5,1).until(EC.presence_of_element_located((By.ID,"capImg"))) except Exception, e: pass # 找不到当前验证码窗口里的ID capImg print(driver.find_element_by_id("capImg").src)
付费偷看金额在0.1-10元之间
一周热门 更多>