《封号码罗》python爬虫之携程登录滑块验证和文字点选验证码(十七)

文字点选是通过调用百度AI的文字识别接口,经过测试验证通过率不解释,能完成登录就行了
# encoding: utf-8
"""
@time: 2021/5/28 9:45
"""
from pprint import pprint
from selenium import webdriver
from selenium.webdriver import ActionChains
import time
import base64
from PIL import Image
from aip import AipOcr
from selenium.webdriver.chrome.options import Options


class UnLockScrapy(object):
    def __init__(self, name, pwd):
        super(UnLockScrapy, self).__init__()
        self.name = name
        self.pwd = pwd
        # self.WAPPID = '百度文字识别appid'
        # self.WAPPKEY = '百度文字识别appkey'
        # self.WSECRETKEY = '百度文字识别secretkey'
        # 百度文字识别sdk客户端
        # self.client = AipOcr(self.WAPPID, self.WAPPKEY, self.WSECRETKEY)
        self.WAPPID = '24*****98'
        self.WAPPKEY = '6BWCE3WjFon*****qjkFcCljK'
        self.WSECRETKEY = 'EKT8FiITv**9MMnjU*****1ujqOsVikS '
        # 百度文字识别sdk客户端
        self.client = AipOcr(self.WAPPID, self.WAPPKEY, self.WSECRETKEY)

        options = Options()
        options.add_argument("--disable-blink-features=AutomationControlled")
        options.add_experimental_option('useAutomationExtension', False)
        options.add_experimental_option('excludeSwitches', ['enable-automation'])
        options.add_argument('--disable-gpu')
        options.add_argument('--no-sandbox')
        options.add_experimental_option("detach", True)
        self.driver = webdriver.Chrome(options=options)
        login_url = "https://passport.ctrip.com/user/login?BackUrl=https%3A%2F%2Fhotels.ctrip.com%2Fhotel%2F6278770.html%23ctm_ref%3Dhod_hp_hot_dl_n_2_7"
        self.driver.get(login_url)
        # driver.maximize_window()
        self.driver.execute_cdp_cmd("Page.addScriptToEvaluateOnNewDocument", {
   
            "source": """
                    Object.defineProperty(navigator, 'webdriver', {
                      get: () => undefined
                    })
                  """
        })
        print("浏览器初始化完成")
        time.sleep(2)

        # 输入账号密码
        input_name = self.driver.find_element_by_id("nloginname")
        input_name.clear()
        input_name.send_keys(self.name
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值