其他分享
首页 > 其他分享> > 超级鹰验证码

超级鹰验证码

作者:互联网

chaojiying.py

 1 #!/usr/bin/env python
 2 # coding:utf-8
 3 
 4 import requests
 5 from hashlib import md5
 6 
 7 
 8 class Chaojiying_Client(object):
 9 
10     def __init__(self, username, password, soft_id):
11         self.username = username
12         password = password.encode('utf8')
13         self.password = md5(password).hexdigest()
14         self.soft_id = soft_id
15         self.base_params = {
16             'user': self.username,
17             'pass2': self.password,
18             'softid': self.soft_id,
19         }
20         self.headers = {
21             'Connection': 'Keep-Alive',
22             'User-Agent': 'Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0)',
23         }
24 
25     def PostPic(self, im, codetype):
26         """
27         im: 图片字节
28         codetype: 题目类型 参考 http://www.chaojiying.com/price.html
29         """
30         params = {
31             'codetype': codetype,
32         }
33         params.update(self.base_params)
34         files = {'userfile': ('ccc.jpg', im)}
35         r = requests.post('http://upload.chaojiying.net/Upload/Processing.php', data=params, files=files,
36                           headers=self.headers)
37         return r.json()
38 
39     def PostPic_base64(self, base64_str, codetype):
40         """
41         im: 图片字节
42         codetype: 题目类型 参考 http://www.chaojiying.com/price.html
43         """
44         params = {
45             'codetype': codetype,
46             'file_base64': base64_str
47         }
48         params.update(self.base_params)
49         r = requests.post('http://upload.chaojiying.net/Upload/Processing.php', data=params, headers=self.headers)
50         return r.json()
51 
52     def ReportError(self, im_id):
53         """
54         im_id:报错题目的图片ID
55         """
56         params = {
57             'id': im_id,
58         }
59         params.update(self.base_params)
60         r = requests.post('http://upload.chaojiying.net/Upload/ReportError.php', data=params, headers=self.headers)
61         return r.json()

 

 

 1 import time
 2 from chaojiying import Chaojiying_Client
 3 from selenium.webdriver import Chrome
 4 from selenium.webdriver.common.by import By
 5 
 6 web = Chrome()
 7 web.get('http://www.chaojiying.com/user/login/')
 8 
 9 # 获取图片字节
10 img = web.find_element(By.XPATH, '/html/body/div[3]/div/div[3]/div[1]/form/div/img').screenshot_as_png
11 chao_ji = Chaojiying_Client('187****008', '******', '93**46')
12 # 获取验证码
13 verify_code = chao_ji.PostPic(img, 1902)['pic_str']
14 # 输入并登录
15 web.find_element(By.XPATH, '/html/body/div[3]/div/div[3]/div[1]/form/p[1]/input').send_keys('1871015008')
16 web.find_element(By.XPATH, '/html/body/div[3]/div/div[3]/div[1]/form/p[2]/input').send_keys('123.com')
17 web.find_element(By.XPATH, '/html/body/div[3]/div/div[3]/div[1]/form/p[3]/input').send_keys(verify_code)
18 time.sleep(5)
19 web.find_element(By.XPATH, '/html/body/div[3]/div/div[3]/div[1]/form/p[4]/input').click()

 

标签:超级,验证码,id,chaojiying,params,codetype,div,self
来源: https://www.cnblogs.com/ang0/p/16474646.html