예제 #1
0
 def __init__(self):
     self.config = get_config()
     self.browser = get_browser(self.config)
     self.wait = WebDriverWait(self.browser,
                               self.config["selenium_timeout"])
     self.cjy_kind = self.config["cjy_kind"]
     self.cjy = ChaoJiYing(self.config["cjy_username"],
                           self.config["cjy_password"],
                           self.config["cjy_soft_id"])
     self.tj = TuJian(self.config["tj_username"],
                      self.config["tj_password"])
예제 #2
0
    def __init__(self):
        INFO("欢迎执行JD全自动退会程序,如有使用问题请加TG群https://t.me/jdMemberCloseAccount进行讨论")
        # 初始化基础配置
        self.config = get_config()
        self.selenium_cfg = get_config()["selenium"]
        self.shop_cfg = get_config()["shop"]
        self.sms_captcha_cfg = get_config()["sms_captcha"]
        self.image_captcha_cfg = get_config()["image_captcha"]
        self.ocr_cfg = self.sms_captcha_cfg["ocr"]

        # 初始化selenium配置
        self.browser = get_browser(self.config)
        self.wait = WebDriverWait(self.browser, self.selenium_cfg["timeout"])
        self.wait_check = WebDriverWait(self.browser,
                                        self.selenium_cfg["check_wait"])

        # 初始化短信验证码配置
        if not self.sms_captcha_cfg["is_ocr"]:
            if not self.sms_captcha_cfg["jd_wstool"]:
                from utils.listener import SmsSocket
                self.sms = SmsSocket()
        elif self.sms_captcha_cfg["is_ocr"]:
            if self.ocr_cfg["type"] == "":
                WARN("当前已开启OCR模式,但是并未选择OCR类型,请在config.yaml补充ocr.type")
                sys.exit(1)
            if self.ocr_cfg["type"] == "baidu":
                from captcha.baidu_ocr import BaiduOCR
                self.baidu_ocr = BaiduOCR(self.ocr_cfg)
            elif self.ocr_cfg["type"] == "aliyun":
                from captcha.aliyun_ocr import AliYunOCR
                self.aliyun_ocr = AliYunOCR(self.ocr_cfg)
            elif self.ocr_cfg["type"] == "easyocr":
                from captcha.easy_ocr import EasyOCR
                self.easy_ocr = EasyOCR()

        # 初始化图形验证码配置
        if self.image_captcha_cfg["type"] == "cjy":
            self.cjy = ChaoJiYing(self.image_captcha_cfg)
        elif self.image_captcha_cfg["type"] == "tj":
            self.tj = TuJian(self.image_captcha_cfg)
        elif self.image_captcha_cfg["type"] == "local":
            pass
        elif self.image_captcha_cfg["type"] == "yolov4":
            self.JDyolo = JDyolocaptcha(self.image_captcha_cfg)
        else:
            WARN("请在config.yaml中补充image_captcha.type")
            sys.exit(1)
예제 #3
0
import json

from utils.config import get_config, get_file
from utils.selenium_browser import get_browser
from selenium.webdriver.support.wait import WebDriverWait
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
from selenium.common.exceptions import WebDriverException

if __name__ == '__main__':
    """
    用于获取web端cookie
    """
    config = get_config()
    config['headless'] = False
    browser = get_browser(config)
    browser.get("https://passport.jd.com/new/login.aspx")
    try:
        wait = WebDriverWait(browser, 35)
        username = wait.until(
            EC.presence_of_element_located((By.CLASS_NAME, 'nickname'))).text
        user = {"userName": username, "cookie": browser.get_cookies()}
        config['users'] = user
        with open(get_file("./config.json"), mode='w', encoding="utf-8") as f:
            json.dump(config, f, indent=4, ensure_ascii=False)
        print("成功添加", username)
    except WebDriverException:
        print("添加失败")
    finally:
        browser.close()
예제 #4
0
    def __init__(self):
        INFO("欢迎执行JD全自动退会程序,如有使用问题请加TG群https://t.me/jdMemberCloseAccount进行讨论")
        INFO("↓  " * 30)

        # 检查版本
        INFO("开始检查项目是否有更新")
        check_version(logger)

        # 检查配置
        INFO("开始检查项目配置完整性")
        verify_configuration(logger)

        # 初始化基础配置
        self.config = get_config()
        self.selenium_cfg = get_config()["selenium"]
        self.shop_cfg = get_config()["shop"]
        self.sms_captcha_cfg = get_config()["sms_captcha"]
        self.image_captcha_cfg = get_config()["image_captcha"]
        self.ocr_cfg = self.sms_captcha_cfg["ocr"]
        self.debug = self.config["debug"]

        # 初始化selenium配置
        self.browser = get_browser(self.config)
        self.wait = WebDriverWait(self.browser, self.selenium_cfg["timeout"])
        self.wait_check = WebDriverWait(self.browser,
                                        self.selenium_cfg["check_wait"])

        # 初始化短信验证码配置
        if not self.sms_captcha_cfg["is_ocr"]:
            if not self.sms_captcha_cfg["jd_wstool"]:
                from utils.listener import SmsSocket
                self.sms = SmsSocket()
        elif self.sms_captcha_cfg["is_ocr"]:
            self.ocr_type = self.ocr_cfg["type"]
            if self.ocr_type == "":
                WARN("当前已开启OCR模式,但是并未选择OCR类型,请在config.yaml补充ocr.type")
                sys.exit(1)
            if self.ocr_type == "baidu":
                from captcha.baidu_ocr import BaiduOCR
                self.baidu_ocr = BaiduOCR(self.ocr_cfg, self.debug)
            elif self.ocr_type == "aliyun":
                from captcha.aliyun_ocr import AliYunOCR
                self.aliyun_ocr = AliYunOCR(self.ocr_cfg, self.debug)
            elif self.ocr_type == "easyocr":
                from captcha.easy_ocr import EasyOCR
                self.easy_ocr = EasyOCR(self.debug)
            elif self.ocr_type == "baidu_fanyi":
                from captcha.baidu_fanyi import BaiduFanYi
                self.baidu_fanyi = BaiduFanYi(self.ocr_cfg, self.debug)
        self.ws_conn_url = self.sms_captcha_cfg["ws_conn_url"]
        self.ws_timeout = self.sms_captcha_cfg["ws_timeout"]

        # 初始化图形验证码配置
        if self.image_captcha_cfg["type"] == "cjy":
            self.cjy = ChaoJiYing(self.image_captcha_cfg)
        elif self.image_captcha_cfg["type"] == "tj":
            self.tj = TuJian(self.image_captcha_cfg)
        elif self.image_captcha_cfg["type"] == "local":
            pass
        elif self.image_captcha_cfg["type"] == "yolov4":
            self.JDyolo = JDyolocaptcha(self.image_captcha_cfg)
        else:
            WARN("请在config.yaml中补充image_captcha.type")
            sys.exit(1)

        # 初始化店铺变量
        # 错误店铺页面数量
        self.wrong_store_page_count = 0
        # 黑名单店铺缓存
        self.black_list_shops = []
        # 会员关闭最大数量
        self.member_close_max_number = self.shop_cfg["member_close_max_number"]
        # 注销成功店铺数量
        self.member_close_count = 0
        # 需要跳过的店铺
        self.need_skip_shops = []
        # 指定注销的店铺
        self.specify_shops = []
        # 页面失效打不开的店铺
        self.failure_store = []
        # 云端数据执行状态
        self.add_remote_shop_data = self.shop_cfg["add_remote_shop_data"]
예제 #5
0
                        )), "勾选协议失败 " + card["brandName"]).click()

                    # 点击加入店铺会员按钮
                    print("===点击加入店铺会员按钮")
                    self.wait.until(
                        EC.presence_of_element_located(
                            (By.XPATH, "//span[text()='确认授权并加入店铺会员']")),
                        "加入店铺会员按钮点击失败 " + card["brandName"]).click()

                    time.sleep(1)
                except Exception as e:
                    print("发生了一点小问题:", e.args)

                    if self.config["debug"]:
                        import traceback
                        traceback.print_exc()
                    sys.exit(1)

            print("本轮店铺已执行完,即将开始获取下一轮店铺")


if __name__ == '__main__':
    from utils.config import get_config
    from utils.selenium_browser import get_browser

    _config_ = get_config("../config.yaml")
    _browser_ = get_browser(_config_, "../")

    obj = JDMemberJoinAccount(_config_, _browser_)
    obj.main()
예제 #6
0
import re

from utils.config import get_config
from utils.selenium_browser import get_browser
from selenium.webdriver.support.wait import WebDriverWait
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
from selenium.common.exceptions import WebDriverException

if __name__ == '__main__':
    """
    用于获取手机端cookie
    """
    browser = get_browser(get_config())
    browser.get("https://plogin.m.jd.com/login/login")
    try:
        wait = WebDriverWait(browser, 135)
        print("请在网页端通过手机号码登录")
        wait.until(EC.presence_of_element_located((By.ID, 'msShortcutMenu')))
        browser.get("https://home.m.jd.com/myJd/newhome.action")
        username = wait.until(EC.presence_of_element_located((By.CLASS_NAME, 'my_header_name'))).text
        pt_key, pt_pin, cookie = "", "", ""
        for _ in browser.get_cookies():
            if _["name"] == "pt_key":
                pt_key = _["value"]
            if _["name"] == "pt_pin":
                pt_pin = _["value"]
            if pt_key and pt_pin:
                break
        cookie = "pt_key=" + pt_key + ";pt_pin=" + pt_pin + ";"
        print("获取的cookie是:" + cookie)