Panda-Learning icon indicating copy to clipboard operation
Panda-Learning copied to clipboard

pdlearn目录下面mydriver.py文件中的

Open admin123-admin opened this issue 5 years ago • 42 comments

看不明白咋解决你的意思我明白如何解决这个问题

admin123-admin avatar Mar 24 '20 02:03 admin123-admin

coding=gbk

from selenium import webdriver from selenium.webdriver.support.ui import WebDriverWait from selenium.webdriver.support import expected_conditions as EC from selenium.common import exceptions from selenium.webdriver.chrome.options import Options from pdlearn import user_agent import os

class Mydriver:

def __init__(self, noimg=True, nohead=True):
    try:
        self.options = Options()
        if os.path.exists("./chrome/chrome.exe"):  # win
            self.options.binary_location = "./chrome/chrome.exe"
        elif os.path.exists("/opt/google/chrome/chrome"):  # linux
            self.options.binary_location = "/opt/google/chrome/chrome"
        if noimg:
            self.options.add_argument('blink-settings=imagesEnabled=false')  # 不加载图片, 提升速度
        if nohead:
            self.options.add_argument('--headless')
            self.options.add_argument('--disable-extensions')
            self.options.add_argument('--disable-gpu')
            self.options.add_argument('--no-sandbox')
        self.options.add_argument('--mute-audio')  # 关闭声音
        self.options.add_argument('--window-size=400,500')
        self.options.add_argument('--window-position=800,0')
        self.options.add_argument('--log-level=3')

        self.options.add_argument('--user-agent={}'.format(user_agent.getheaders()))
        self.options.add_experimental_option('excludeSwitches', ['enable-automation'])  # 绕过js检测
        self.webdriver = webdriver
        if os.path.exists("./chrome/chromedriver.exe"):  # win
            self.driver = self.webdriver.Chrome(executable_path="./chrome/chromedriver.exe",
                                                chrome_options=self.options)
        elif os.path.exists("./chromedriver"):  # linux
            self.driver = self.webdriver.Chrome(executable_path="./chromedriver",
                                                chrome_options=self.options)
        elif os.path.exists("/usr/lib64/chromium-browser/chromedriver"):  # linux 包安装chromedriver
            self.driver = self.webdriver.Chrome(executable_path="/usr/lib64/chromium-browser/chromedriver",
                                                chrome_options=self.options)
        elif os.path.exists("/usr/local/bin/chromedriver"):  # linux 包安装chromedriver
            self.driver = self.webdriver.Chrome(executable_path="/usr/local/bin/chromedriver",
                                                chrome_options=self.options)
        else:
            self.driver = self.webdriver.Chrome(chrome_options=self.options)
    except:
        print("=" * 120)
        print("Mydriver初始化失败")
        print("=" * 120)
        raise


def login(self):
    print("正在打开二维码登陆界面,请稍后")
    self.driver.get("https://pc.xuexi.cn/points/login.html")
    try:
        remover = WebDriverWait(self.driver, 30, 0.2).until(
            lambda driver: driver.find_element_by_class_name("redflagbox"))
    except exceptions.TimeoutException:
        print("网络缓慢,请重试")
    else:
        self.driver.execute_script('arguments[0].remove()', remover)
    try:
        remover = WebDriverWait(self.driver, 30, 0.2).until(
            lambda driver: driver.find_element_by_class_name("header"))
    except exceptions.TimeoutException:
        print("当前网络缓慢...")
    else:
        self.driver.execute_script('arguments[0].remove()', remover)
    try:
        remover = WebDriverWait(self.driver, 30, 0.2).until(
            lambda driver: driver.find_element_by_class_name("footer"))
    except exceptions.TimeoutException:
        print("当前网络缓慢...")
    else:
        self.driver.execute_script('arguments[0].remove()', remover)
        self.driver.execute_script('window.scrollTo(document.body.scrollWidth/2 - 200 , 0)')
    try:
        WebDriverWait(self.driver, 270).until(EC.title_is(u"系统维护中"))
        cookies = self.get_cookies()
        return cookies
    except:
        print("扫描二维码超时")

def dd_login(self, d_name, pwd):
    __login_status = False
    self.driver.get(
        "https://login.dingtalk.com/login/index.htm?"
        "goto=https%3A%2F%2Foapi.dingtalk.com%2Fconnect%2Foauth2%2Fsns_authorize"
        "%3Fappid%3Ddingoankubyrfkttorhpou%26response_type%3Dcode%26scope%3Dsnsapi"
        "_login%26redirect_uri%3Dhttps%3A%2F%2Fpc-api.xuexi.cn%2Fopen%2Fapi%2Fsns%2Fcallback"
    )
    self.driver.find_elements_by_id("mobilePlaceholder")[0].click()
    self.driver.find_element_by_id("mobile").send_keys(d_name)
    self.driver.find_elements_by_id("mobilePlaceholder")[1].click()
    self.driver.find_element_by_id("pwd").send_keys(pwd)
    self.driver.find_element_by_id("loginBtn").click()
    try:
        print("登陆中...")
        WebDriverWait(self.driver, 2, 0.1).until(lambda driver: driver.find_element_by_class_name("modal"))
        print(self.driver.find_element_by_class_name("modal").find_elements_by_tag_name("div")[0].text)
        self.driver.quit()
        __login_status = False
    except:
        __login_status = True
    return __login_status

def get_cookies(self):
    cookies = self.driver.get_cookies()
    return cookies

def set_cookies(self, cookies):
    for cookie in cookies:
        self.driver.add_cookie({k: cookie[k] for k in cookie.keys()})

def get_url(self, url):
    self.driver.get(url)

def go_js(self, js):
    self.driver.execute_script(js)

def quit(self):
    self.driver.quit()

adslhuang avatar Mar 24 '20 03:03 adslhuang

用上面的内容代替源文件

adslhuang avatar Mar 24 '20 03:03 adslhuang

你qq发给我控制我电脑看看把嘻嘻小白我[email protected]

admin123-admin avatar Mar 24 '20 03:03 admin123-admin

这也是我qq

admin123-admin avatar Mar 24 '20 03:03 admin123-admin

或者你把更新好的软件发出来哈哈大神

admin123-admin avatar Mar 24 '20 03:03 admin123-admin

修改mydriver.py里面的url为https://pc.xuexi.cn/points/login.html?ref=https://pc.xuexi.cn/points/my-study.html即可。

shingoxy avatar Mar 24 '20 06:03 shingoxy

再重新pyinstaller进行exe打包覆盖原文件即可。附上我修改打包ok的exe。 pandalearning.zip

shingoxy avatar Mar 24 '20 06:03 shingoxy

为什么下载不了你试试qq传给我兄弟谢谢你

------------------ 原始邮件 ------------------ 发件人: "ShingoXY"<[email protected]>; 发送时间: 2020年3月24日(星期二) 下午2:48 收件人: "Alivon/Panda-Learning"<[email protected]>; 抄送: "温柔的女汉子"<[email protected]>; "Author"<[email protected]>; 主题: Re: [Alivon/Panda-Learning] pdlearn目录下面mydriver.py文件中的 (#500)

再重新pyinstaller进行exe打包覆盖原文件即可。附上我修改打包ok的exe。 pandalearning.zip

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe.

admin123-admin avatar Mar 24 '20 06:03 admin123-admin

我替换好了还不行

------------------ 原始邮件 ------------------ 发件人: "ShingoXY"<[email protected]>; 发送时间: 2020年3月24日(星期二) 下午2:48 收件人: "Alivon/Panda-Learning"<[email protected]>; 抄送: "温柔的女汉子"<[email protected]>; "Author"<[email protected]>; 主题: Re: [Alivon/Panda-Learning] pdlearn目录下面mydriver.py文件中的 (#500)

再重新pyinstaller进行exe打包覆盖原文件即可。附上我修改打包ok的exe。 pandalearning.zip

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe.

admin123-admin avatar Mar 24 '20 07:03 admin123-admin

不会啊,我测试OK才上传的

shingoxy avatar Mar 24 '20 09:03 shingoxy

真的下载不了我试了手机电脑都不行你QQ穿给我文件发给我试试看------------------ 原始邮件 ------------------ 发件人: "ShingoXY"[email protected] 发送时间: 2020年3月24日(星期二) 下午5:19 收件人: "Alivon/Panda-Learning"[email protected]; 抄送: "admin123-admin"[email protected];"Author"[email protected]; 主题: Re: [Alivon/Panda-Learning] pdlearn目录下面mydriver.py文件中的 (#500)

不会啊,我测试OK才上传的

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe.

admin123-admin avatar Mar 24 '20 09:03 admin123-admin

不会啊,我测试OK才上传的

大佬,不能下载,发个邮箱谢谢,好人一生平安[email protected]

wwdy125 avatar Mar 24 '20 09:03 wwdy125

好多人都不能下载

------------------ 原始邮件 ------------------ 发件人: "ShingoXY"<[email protected]>; 发送时间: 2020年3月24日(星期二) 下午5:19 收件人: "Alivon/Panda-Learning"<[email protected]>; 抄送: "温柔的女汉子"<[email protected]>; "Author"<[email protected]>; 主题: Re: [Alivon/Panda-Learning] pdlearn目录下面mydriver.py文件中的 (#500)

不会啊,我测试OK才上传的

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe.

admin123-admin avatar Mar 24 '20 09:03 admin123-admin

链接: https://pan.baidu.com/s/1cYEaorlMj_GhV0ti8eLCWQ 提取码: msvv 复制这段内容后打开百度网盘手机App,操作更方便哦

shingoxy avatar Mar 24 '20 09:03 shingoxy

感谢大佬

wwdy125 avatar Mar 24 '20 09:03 wwdy125

image 用大佬的文体替代了,在这里停留了起码5分钟,最后终于开始学习了,谢谢大佬!

3255slayer avatar Mar 24 '20 11:03 3255slayer

为什么我家电脑64位的打开就闪退打开32位的没事不过还是系统维护

admin123-admin avatar Mar 24 '20 11:03 admin123-admin

image 用大佬的文体替代了,在这里停留了起码5分钟,最后终于开始学习了,谢谢大佬!

你能发一下你的软件的文件给我吗qq1960971987我试了替换了打开按两下回车会闪退

admin123-admin avatar Mar 24 '20 12:03 admin123-admin

链接:https ://pan.baidu.com/s/1cYEaorlMj_GhV0ti8eLCWQ提取代码:msvv复制这段内容后打开百度网盘手机应用程序,操作更方便哦 非常感谢!

CN-Willaim avatar Mar 24 '20 12:03 CN-Willaim

image 用大佬的文体替代了,在这里停留了起码5分钟,最后终于开始学习了,谢谢大佬!

你能发一下你的软件的文件给我吗qq1960971987我试了替换了打开按两下回车会闪退

链接:https ://pan.baidu.com/s/1cYEaorlMj_GhV0ti8eLCWQ提取代码:msvv

3255slayer avatar Mar 24 '20 12:03 3255slayer

我下载替换了你们谁能把能用的直接发过来我试试看!!

admin123-admin avatar Mar 24 '20 12:03 admin123-admin

再重新pyinstaller进行exe打包覆盖原文件即可。附上我修改打包ok的exe。 pandalearning.zip

下载大佬在这里发出的这个连接吧

3255slayer avatar Mar 24 '20 12:03 3255slayer

我下载替换了你们谁能把能用的直接发过来我试试看!!

解压缩后右键,给与管理员权限运行,兼容性可以选xp

3255slayer avatar Mar 24 '20 12:03 3255slayer

不会啊,我测试OK才上传的 Uploading image.png…

Jasonandy avatar Mar 24 '20 13:03 Jasonandy

感谢感谢!!!

2449851453 avatar Mar 24 '20 16:03 2449851453

下载pandalearning.zip解压之后替换源文件就可以正常扫码登入了,感谢感谢!

上面的百度链接

链接:https://pan.baidu.com/s/1cYEaorlMj_GhV0ti8eLCWQ提取代码:msvv复制这段内容后打开百度网盘手机应用程序,操作更方便哦

-1bf85a3cca86fd86

2449851453 avatar Mar 24 '20 16:03 2449851453

发现文章学习线程偶尔会出问题(最近出现的,之前没有),导致文章不被学习。把错误代码发上来看看 Exception in thread 文章学习: Traceback (most recent call last): File "threading.py", line 926, in _bootstrap_inner File "pdlearn\threads.py", line 23, in run File "pandalearning.py", line 66, in article IndexError: list index out of range

gundamgx avatar Mar 24 '20 23:03 gundamgx

改代码上面有人已经回复了,其实就改了一个网址,不影响其他地方。

shingoxy avatar Mar 25 '20 01:03 shingoxy

再重新pyinstaller进行exe打包覆盖原文件即可。附上我修改打包ok的exe。 pandalearning.zip

能否封装一个32位的EXE,我32位电脑没法用你这个64位的EXE

johnny46 avatar Mar 25 '20 11:03 johnny46

再重新pyinstaller进行exe打包覆盖原文件即可。附上我修改打包ok的exe。 pandalearning.zip

能否封装一个32位的EXE,我32位电脑没法用你这个64位的EXE

额我Python是64bit的。。。。

shingoxy avatar Mar 26 '20 01:03 shingoxy