使用超级鹰破解超级鹰网站时出现错误
我使用超级鹰提供的pythonDemo去破解超级鹰页面的验证码出现了问题,获取到的验证码无法输入到验证码的框里,而且程序结束后还会自动关闭页面,我明明没写让它关闭的程序{:10_266:}源代码:
from selenium.webdriver import Chrome
from selenium.webdriver.common.by import By
from chaojiying import Chaojiying_Client
import time
web = Chrome()
#打开网页
web.get('http://www.chaojiying.com/user/login/')
time.sleep(1)
#获取验证码
img = web.find_element(by=By.XPATH,value='/html/body/div/div/div/div/form/div/img').screenshot('yanzhengma.png')
chaojiying = Chaojiying_Client('1473779175', '1473779175', '931325')
dic = chaojiying.PostPic(img, 1902)
verify_code = dic['pic_str']
#输入账号密码
web.find_element(by=By.XPATH,value='/html/body/div/div/div/div/form/p/input').send_keys('1473779175')
web.find_element(by=By.XPATH,value='/html/body/div/div/div/div/form/p/input').send_keys('1473779175')
web.find_element(by=By.XPATH,value='/html/body/div/div/div/div/form/p/input').send_keys(verify_code)
time.sleep(5)
#点击登录
web.find_element(by=By.XPATH,value='/html/body/div/div/div/div/form/p/input').click() 第一:
screenshot 得到的返回值是 True,即 img 为 True ,
并不是验证码图片,所以当然识别不出来了,你应该把图片读取出来
第二:
程序运行结束了,基于你的程序运行的浏览器当然会跟着结束了,
你可以在最后面加个 input() 阻塞一下
第三:
你应该改密码了
对你的程序修改如下:
from selenium.webdriver import Chrome
from selenium.webdriver.common.by import By
from chaojiying import Chaojiying_Client
import time
web = Chrome()
#打开网页
web.get('http://www.chaojiying.com/user/login/')
time.sleep(1)
#获取验证码
img = web.find_element(by=By.XPATH,value='/html/body/div/div/div/div/form/div/img').screenshot('yanzhengma.png')
chaojiying = Chaojiying_Client('1473779175', '1473779175', '931325')
with open('yanzhengma.png', 'rb') as f: # 注意这里
content = f.read() # 注意这里
dic = chaojiying.PostPic(content, 1902) # 注意这里
verify_code = dic['pic_str']
#输入账号密码
web.find_element(by=By.XPATH,value='/html/body/div/div/div/div/form/p/input').send_keys('1473779175')
web.find_element(by=By.XPATH,value='/html/body/div/div/div/div/form/p/input').send_keys('1473779175')
web.find_element(by=By.XPATH,value='/html/body/div/div/div/div/form/p/input').send_keys(verify_code)
time.sleep(5)
#点击登录
web.find_element(by=By.XPATH,value='/html/body/div/div/div/div/form/p/input').click()
input() # 注意这里
页:
[1]