Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
admin123-admin opened this issue Mar 24, 2020 · 42 comments
Open

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

admin123-admin opened this issue Mar 24, 2020 · 42 comments

Comments

@admin123-admin
Copy link

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

@adslhuang
Copy link

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
Copy link

用上面的内容代替源文件

@admin123-admin
Copy link
Author

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

@admin123-admin
Copy link
Author

这也是我qq

@admin123-admin
Copy link
Author

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

@shingoxy
Copy link

@shingoxy
Copy link

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

@admin123-admin
Copy link
Author

admin123-admin commented Mar 24, 2020 via email

@admin123-admin
Copy link
Author

admin123-admin commented Mar 24, 2020 via email

@shingoxy
Copy link

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

@admin123-admin
Copy link
Author

admin123-admin commented Mar 24, 2020 via email

@wwdy125
Copy link

wwdy125 commented Mar 24, 2020

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

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

@admin123-admin
Copy link
Author

admin123-admin commented Mar 24, 2020 via email

@shingoxy
Copy link

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

@wwdy125
Copy link

wwdy125 commented Mar 24, 2020

感谢大佬

@3255slayer
Copy link

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

@admin123-admin
Copy link
Author

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

@admin123-admin
Copy link
Author

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

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

@CN-Willaim
Copy link

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

@3255slayer
Copy link

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

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

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

@admin123-admin
Copy link
Author

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

@3255slayer
Copy link

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

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

@3255slayer
Copy link

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

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

@Jasonandy
Copy link

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

@2449851453
Copy link

感谢感谢!!!

@2449851453
Copy link

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

上面的百度链接

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

-1bf85a3cca86fd86

@gundamgx
Copy link

发现文章学习线程偶尔会出问题(最近出现的,之前没有),导致文章不被学习。把错误代码发上来看看
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

@shingoxy
Copy link

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

@johnny46
Copy link

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

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

@shingoxy
Copy link

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

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

额我Python是64bit的。。。。

@vivoosz
Copy link

vivoosz commented Mar 26, 2020

今天下午突然发现二维码的图片显示不了,请问大家遇到了吗?

@boowolf
Copy link

boowolf commented Mar 26, 2020

遇到了,不显示,好像是浏览器被禁止显示图片了,但是改不了。

@vivoosz
Copy link

vivoosz commented Mar 26, 2020

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')

是不是启动CHROME时屏蔽图片的问题?我用普通浏览器直接打开URL是会加载图片的。手上没有源码,有没有大佬重新打包下试试~~

@c838341469
Copy link

二维码图片显示不了 哭了

@admin123-admin
Copy link
Author

用别的浏览器打开会加载,这个Chrome打开就不会加载图片

@ruyidada
Copy link

二维码不加载了

@shingoxy
Copy link

链接: https://pan.baidu.com/s/13GXMmMgJaWC5Y8TZmuKjoA 提取码: bu5s
64bit版本,已修改不能显示图片部分,自测可用,按需自取。

@johnny46
Copy link

链接: https://pan.baidu.com/s/13GXMmMgJaWC5Y8TZmuKjoA 提取码: bu5s
64bit版本,已修改不能显示图片部分,自测可用,按需自取。

大佬,能否做个32bit的版本,不胜感激

@shingoxy
Copy link

链接: https://pan.baidu.com/s/13GXMmMgJaWC5Y8TZmuKjoA 提取码: bu5s
64bit版本,已修改不能显示图片部分,自测可用,按需自取。

大佬,能否做个32bit的版本,不胜感激

链接: https://pan.baidu.com/s/1WHkBjt_xC6aEZJlIEP16CA 提取码: txe6
我自己的电脑会被认为是木马,我64bit系统测试没问题,你试试吧。

@vivoosz
Copy link

vivoosz commented Mar 27, 2020

链接: https://pan.baidu.com/s/13GXMmMgJaWC5Y8TZmuKjoA 提取码: bu5s
64bit版本,已修改不能显示图片部分,自测可用,按需自取。

感谢!

@zxminglj
Copy link

把mydriver.py里头的false改成true即可解决

@18958092381
Copy link

修改好了.请问大家钉钉接口还能用吗?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests