Ejemplo n.º 1
0
 def pick_code(self):
     time.sleep(1)
     pick_img_label = self.browser.find_element_by_css_selector(
         'img.geetest_item_img')  # 获取点触图片标签
     src = pick_img_label.get_attribute('src')  # 获取点触图片链接
     img_content = requests.get(src).content  # 获取图片二进制内容
     f = BytesIO()
     f.write(img_content)
     img0 = Image.open(f)  # 将图片以文件的形式打开,主要是为了获取图片的大小
     scale = [
         pick_img_label.size['width'] / img0.size[0],
         pick_img_label.size['height'] / img0.size[1]
     ]  # 获取图片与浏览器该标签大小的比例
     cjy = chaojiying.Chaojiying_Client('*******', '******',
                                        '901489')  # 登录超级鹰
     result = cjy.PostPic(img_content, '9005')  # 发送图片并获取结果
     if result['err_no'] == 0:  # 对结果进行分析
         position = result['pic_str'].split(
             '|')  # position = ['110,234','145,247','25,185']
         position = [[int(j) for j in i.split(',')] for i in position
                     ]  # position = [[110,234],[145,247],[25,185]]
         for items in position:  # 模拟点击
             ActionChains(self.browser).move_to_element_with_offset(
                 pick_img_label, items[0] * scale[0],
                 items[1] * scale[1]).click().perform()
             time.sleep(1)
         certern_btn = self.browser.find_element_by_css_selector(
             'div.geetest_commit_tip')
         certern_btn.click()
     return cjy, result
Ejemplo n.º 2
0
 def __init__(self):
     self.cjy = chaojiying.Chaojiying_Client("sunbofu", "awgmRFEHbKSe.u7", "909639")
     self.last_status = True
     self.real_count = 0
     self.follow_json = {}
     self.last_follow = None
     self.validate_config()
Ejemplo n.º 3
0
def captcha_discern(chaojicode):
    client = chaojiying.Chaojiying_Client('geekyh', '1380013800',
                                          '911387')  #依次输入超级鹰平台的 用户名,密码,软件ID
    with open(chaojicode, 'rb') as f:
        image = f.read()
        #print(chaojicode)
        captcha = client.PostPic(image, 1902)['pic_str']
    print('captcha discerned: ' + captcha)
    return captcha
Ejemplo n.º 4
0
 def _chaojiying(self):
     cjy = chaojiying.Chaojiying_Client(self.chaojiying_name,
                                        self.chaojiying_pwd,
                                        self.chaojiying_soft_id)
     im = open("captcha.png", "rb").read()
     # {'err_no': 0, 'err_str': 'OK', 'pic_id': '9073610502616700001', 'pic_str': '3rhr', 'md5': 'e18ed33cf0007d024657a41706e91f59'}
     captcha_code = cjy.PostPic(im,
                                self.chaojiying_code_type).get("pic_str")
     print("当前验证码是:", captcha_code)
     return captcha_code
Ejemplo n.º 5
0
 async def get_captcha_code(self):
     catpcha_img_url = await self.page.evaluate("""()=>{
         return document.getElementById("chkImg").src
         }
         """)
     catpcha_img_url = urljoin("https://checkimage.etest.edu.cn/",
                               catpcha_img_url)
     response = requests.get(url=catpcha_img_url)
     cjy = chaojiying.Chaojiying_Client(self.chaojiying_name,
                                        self.chaojiying_pwd,
                                        self.chaojiying_soft_id)
     captcha_code = cjy.PostPic(response.content,
                                self.chaojiying_code_type).get("pic_str")
     if not captcha_code:
         captcha_code = "aaaa"
     print("当前验证码是:", captcha_code)
     return captcha_code
Ejemplo n.º 6
0
def postCmnt(session, postUrl, request, response):
    # 设置超级鹰
    CHAOJIYING_USERNAME = '******'
    CHAOJIYING_PASSWORD = '******'
    CHAOJIYING_SOFT_ID = 907319
    CHAOJIYING_KIND = 3008
    CHAOJIYING = chaojiying.Chaojiying_Client(CHAOJIYING_USERNAME,
                                              CHAOJIYING_PASSWORD,
                                              CHAOJIYING_SOFT_ID)

    data = composeCmnt(session._session, response)

    html = session.get(postUrl).text  #需要评论的帖子
    r1 = re.compile(r'captcha.*?src="(.*?)"')  #验证码
    pic = re.findall(r1, html)
    #有验证码
    if pic:
        dd = pic[0].split('=')[-1]
        data['captcha-id'] = dd  #re.findall('id=(.*?)&', pic[0])[0]
        with open('captcha/' + dd.split(':')[0] + '.jpg', 'wb') as f:
            f.write(session.get('https:' + pic[0]).content)
            print("%s下载完成" % pic)
        im = open('captcha/' + dd.split(':')[0] + '.jpg', 'rb').read()
        data['captcha-solution'] = CHAOJIYING.PostPic(
            im, CHAOJIYING_KIND)['pic_str']

    cmntUrl = postUrl + 'add_comment'
    r = session.post(cmntUrl, data=data,
                     headers={'Referer':
                              postUrl})  #, files=response.get('files'))
    # r = session.get(postUrl)
    code = str(r.status_code)
    success = str(r.url).split('/')[-1]

    if (code.startswith('4')
            or code.startswith('5')) and not code.startswith('404'):
        log.error(r.status_code)
        raise Exception
    else:
        log.info("Success.", request + '  --' + data['rv_comment'])
    '''
Ejemplo n.º 7
0
    def process_captcha_code(self, html, pdf):
        """Process the html text of captcha page."""
        soup = BeautifulSoup(html, 'html.parser')
        captcha_url_pre = '/'.join(pdf['pdf_url'].split('/')[:3])
        captcha_img_url = captcha_url_pre + soup.find('img').attrs['src']
        with open('./captcha_code.jpg', 'wb') as img:
            img.write(self.sess.get(captcha_img_url).content)

        # Try 10 times at most.
        for i in range(10):
            chaojy = chaojiying.Chaojiying_Client('***YourUserName***',
                                                  '***YourPassword***', '')
            im = open('captcha_code.jpg', 'rb').read()

            # 3008 means the captcha only contains 1~8 English letters. Please see: https://www.chaojiying.com/price.html
            temp_dict = chaojy.PostPic(im, 3008)
            print(temp_dict['pic_str'])

            captcha_data = {}
            captcha_data['id'] = soup.find('input', {
                'type': 'hidden',
                'name': 'id'
            }).attrs['value']
            captcha_data['answer'] = temp_dict['pic_str']
            res = self.sess.post(pdf['pdf_url'],
                                 data=captcha_data,
                                 stream=True)

            if self.is_captcha_page(res):
                chaojy.ReportError(temp_dict['pic_id'])
            else:
                return res
        print(
            STD_WARNING +
            'I have tried it 10 times but it did not work. Please download this file manually.'
        )
        return res
Ejemplo n.º 8
0
    labeluser = tk.Label(window, text="请输入账号")
    labeluser.pack()
    inputuser = tk.Entry(window, width=30)
    inputuser.pack()
    labelpassword = tk.Label(window, text="请输入密码")
    labelpassword.pack()
    inputpassword = tk.Entry(window, width=30)
    inputpassword.pack()
    btn = tk.Button(window, text='Login', command=lambda: thread_it(run))
    btn.pack()
    lb = tk.Listbox(window)
    scr = tk.Scrollbar(window)
    lb.config(yscrollcommand=scr.set)
    scr.config(command=lb.yview)
    lb.pack(side=tk.LEFT, expand=tk.YES, fill=tk.BOTH)
    scr.pack(side=tk.RIGHT, fill=tk.Y)
    chaojiying = chaojiying.Chaojiying_Client(
        '', '', ''
    )  # 用户中心>>软件ID 生成一个替换 96001  # 本地图片文件路径 来替换 a.jpg 有时WIN系统须要//									#1902 验证码类型
    chrome_options = Options()
    # # 设置chrome浏览器无界面模式
    chrome_options.add_argument('--headless')
    chrome_options.add_argument("--mute-audio")
    # webdriver.Firefox(executable_path='.\Google\Chrome\Application\chrome.exe')
    driver = webdriver.Chrome(r'./settings/chromedriver.exe',
                              chrome_options=chrome_options)
    driver.maximize_window()
    driver.implicitly_wait(60)
    wait = WebDriverWait(driver, 3600, 0.5)
    window.mainloop()
Ejemplo n.º 9
0
    def login(self):
        self.driver = webdriver.Chrome(executable_path='D:\chromedriver.exe')

        with open('D:\stealth.min.js') as f:
            stealth = f.read()
        self.driver.execute_cdp_cmd('Page.addScriptToEvaluateOnNewDocument',
                                    {"source": stealth})

        self.wait = WebDriverWait(self.driver, 10, 0.1)
        self.driver.get(self.login_url)

        self.wait.until(self.findElement(By.LINK_TEXT, '账号登录')).click()

        self.wait.until(self.findElement(By.ID, 'J-userName')).send_keys(
            self.username)

        self.wait.until(self.findElement(By.ID, 'J-password')).send_keys(
            self.password)

        time.sleep(20)

        success_flag = self.wait.until(
            EC.presence_of_element_located(
                (By.CLASS_NAME, 'lgcode-success'))).get_attribute('style')
        while success_flag == 'display: none;':
            img = self.wait.until(
                EC.visibility_of_element_located((By.ID, 'J-loginImg')))

            base64Img = img.get_attribute('src')
            base64Img = base64Img.replace('data:image/jpg;base64,', '')
            imgdata = base64.urlsafe_b64decode(base64Img)
            file = open('1.jpg', 'wb')
            file.write(imgdata)
            file.close()

            cj = chaojiying.Chaojiying_Client('用户名', '密码', '软件ID')
            im = open('1.jpg', 'rb').read()
            cjy_result = cj.PostPic(im, 9004)
            print(cjy_result)
            x_y = cjy_result['pic_str']
            pic_id = cjy_result['pic_id']

            all_list = []
            for i in x_y.split('|'):
                all_list.append([int(i.split(',')[0]), int(i.split(',')[1])])

            for rangle in all_list:
                ActionChains(self.driver).move_to_element_with_offset(
                    img, rangle[0], rangle[1]).click().perform()

            self.wait.until(self.findElement(By.ID, 'J-login')).click()
            success_flag = self.driver.find_element_by_class_name(
                'lgcode-success').get_attribute('style')

            if success_flag == 'display: none;':
                cj.ReportError(pic_id)

        nc_1_n1z = self.wait.until(self.findElement(By.ID, 'nc_1_n1z'))
        tracks = [6, 16, 31, 52, 72, 52, 62, 50]

        action = ActionChains(self.driver)

        action.click_and_hold(nc_1_n1z).perform()
        for track in tracks:
            action.move_by_offset(track, 0)
        time.sleep(0.5)
        action.release().perform()
Ejemplo n.º 10
0
location = code_img_ele.location
print(location)
# 验证码图片的尺寸
size = code_img_ele.size
print(size)
# 左上角和右上角的坐标
rangle = (int(location['x']), int(location['y']),
          int(location['x'] + size['width']),
          int(location['y'] + size['height']))
print(rangle)
i = Image.open('./a.png')
code_img_name = './code.png'
frame = i.crop(rangle)
frame.save(code_img_name)

chaojiying = chaojiying.Chaojiying_Client('Eric54920', 'Eric54920!', '901421')
im = open('code.png', 'rb').read()
ret = chaojiying.PostPic(im, 9004)

if ret['err_str'] == 'OK':
    result = ret['pic_str']
else:
    chaojiying.ReportError(ret['pic_id'])

all_list = []
if '|' in result:
    list = result.split('|')
    for i in range(len(list)):
        xy_list = []
        x = int(list[i].split(',')[0])
        y = int(list[i].split(',')[1])
Ejemplo n.º 11
0
import chaojiying
from urllib import request
import time
import os
jpg_link="http://192.168.2.200:8081/verifycode"  #图片链接
rq=time.strftime("%H-%M-%S",time.localtime())
dir_path=os.path.dirname(os.path.abspath(__file__))
path=os.path.join(dir_path,rq+'.png')#t图片保存路径及名称
request.urlretrieve(jpg_link, path)#下载保存图片
time.sleep(1)
chaojiying = chaojiying.Chaojiying_Client('xhj123456', 'qazwsx123', '899485')	#用户中心>>软件ID 生成一个替换 96001
im = open(path, 'rb').read()
print (chaojiying.PostPic(im, 1902))
a=chaojiying.PostPic(im,1902)["pic_str"]

Ejemplo n.º 12
0
def verifyCode(img):
    client = chaojiying.Chaojiying_Client('c3730915', '9DpxzsJbNBJLB.F', '913619')
    data = client.PostPic(img,"4004")
    print(data)
    return (data['pic_str'])
Ejemplo n.º 13
0
def get_code(png):
    cjy = chaojiying.Chaojiying_Client(CJY_USERNAME, CJY_PASSWORD, CJY_SOFT_ID)  # 用户中心>>软件ID 生成一个替换 96001
    im = open(png, 'rb').read()   # 本地图片文件路径 来替换 a.jpg 有时WIN系统须要//
    result = cjy.PostPic(im, CJY_KIND)
    code = result['pic_str']
    return code