Title

打码平台

### 打码平台

```python
mport time
from selenium import webdriver
from selenium.webdriver.common.by import By
from chaojiying import Chaojiying_Client
from PIL import Image

browser = webdriver.Chrome()
browser.get('https://www.chaojiying.com/user/login/')
browser.implicitly_wait(10)
browser.maximize_window()
try:
    username = browser.find_element(By.CSS_SELECTOR,
                                    'body > div.wrapper_danye > div > div.content_login > div.login_form > form > p.login_form_item > input')
    password = browser.find_element(By.CSS_SELECTOR,
                                    'body > div.wrapper_danye > div > div.content_login > div.login_form > form > p:nth-child(2) > input')
    code = browser.find_element(By.CSS_SELECTOR,
                                'body > div.wrapper_danye > div > div.content_login > div.login_form > form > p:nth-child(4) > input')
    btn = browser.find_element(By.CSS_SELECTOR,
                               'body > div.wrapper_danye > div > div.content_login > div.login_form > form > p:nth-child(5) > input')
    username.send_keys('')
    password.send_keys('')
    browser.save_screenshot('main.png')
    img = browser.find_element(By.CSS_SELECTOR,
                               'body > div.wrapper_danye > div > div.content_login > div.login_form > form > div > img')
    location = img.location
    size = img.size
    img_size = (int(location['x']) * 1.5, int(location['y']) * 1.5, int(location['x'] + size['width']) * 1.5,
                int(location['y'] + size['height']) * 1.5)
    img = Image.open('./main.png')
    fram = img.crop(img_size)
    fram.save('code.png')
    chaojiying = Chaojiying_Client('', '', '')  # 用户中心>>软件ID 生成一个替换 96001
    im = open('code.png', 'rb').read()
    print(chaojiying.PostPic(im, 1902))
    res_code = chaojiying.PostPic(im, 1902)["pic_str"]
    code.send_keys(res_code)
    time.sleep(5)
    btn.click()
    time.sleep(10)
except Exception as e:
    print(e)

finally:
    browser.close()

posted @ 2023-07-11 18:14  哈哈哈哼  阅读(178)  评论(0编辑  收藏  举报