Giter Club home page Giter Club logo

Comments (42)

adslhuang avatar adslhuang commented on June 27, 2024

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

from panda-learning.

adslhuang avatar adslhuang commented on June 27, 2024

用上面的内容代替源文件

from panda-learning.

admin123-admin avatar admin123-admin commented on June 27, 2024

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

from panda-learning.

admin123-admin avatar admin123-admin commented on June 27, 2024

这也是我qq

from panda-learning.

admin123-admin avatar admin123-admin commented on June 27, 2024

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

from panda-learning.

shingoxy avatar shingoxy commented on June 27, 2024

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

from panda-learning.

shingoxy avatar shingoxy commented on June 27, 2024

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

from panda-learning.

admin123-admin avatar admin123-admin commented on June 27, 2024

from panda-learning.

admin123-admin avatar admin123-admin commented on June 27, 2024

from panda-learning.

shingoxy avatar shingoxy commented on June 27, 2024

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

from panda-learning.

admin123-admin avatar admin123-admin commented on June 27, 2024

from panda-learning.

wwdy125 avatar wwdy125 commented on June 27, 2024

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

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

from panda-learning.

admin123-admin avatar admin123-admin commented on June 27, 2024

from panda-learning.

shingoxy avatar shingoxy commented on June 27, 2024

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

from panda-learning.

wwdy125 avatar wwdy125 commented on June 27, 2024

感谢大佬

from panda-learning.

3255slayer avatar 3255slayer commented on June 27, 2024

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

from panda-learning.

admin123-admin avatar admin123-admin commented on June 27, 2024

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

from panda-learning.

admin123-admin avatar admin123-admin commented on June 27, 2024

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

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

from panda-learning.

CN-Willaim avatar CN-Willaim commented on June 27, 2024

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

from panda-learning.

3255slayer avatar 3255slayer commented on June 27, 2024

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

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

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

from panda-learning.

admin123-admin avatar admin123-admin commented on June 27, 2024

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

from panda-learning.

3255slayer avatar 3255slayer commented on June 27, 2024

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

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

from panda-learning.

3255slayer avatar 3255slayer commented on June 27, 2024

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

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

from panda-learning.

Jasonandy avatar Jasonandy commented on June 27, 2024

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

from panda-learning.

2449851453 avatar 2449851453 commented on June 27, 2024

感谢感谢!!!

from panda-learning.

2449851453 avatar 2449851453 commented on June 27, 2024

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

上面的百度链接

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

-1bf85a3cca86fd86

from panda-learning.

gundamgx avatar gundamgx commented on June 27, 2024

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

from panda-learning.

shingoxy avatar shingoxy commented on June 27, 2024

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

from panda-learning.

johnny46 avatar johnny46 commented on June 27, 2024

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

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

from panda-learning.

shingoxy avatar shingoxy commented on June 27, 2024

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

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

额我Python是64bit的。。。。

from panda-learning.

vivoosz avatar vivoosz commented on June 27, 2024

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

from panda-learning.

boowolf avatar boowolf commented on June 27, 2024

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

from panda-learning.

vivoosz avatar vivoosz commented on June 27, 2024

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是会加载图片的。手上没有源码,有没有大佬重新打包下试试~~

from panda-learning.

c838341469 avatar c838341469 commented on June 27, 2024

二维码图片显示不了 哭了

from panda-learning.

admin123-admin avatar admin123-admin commented on June 27, 2024

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

from panda-learning.

ruyidada avatar ruyidada commented on June 27, 2024

二维码不加载了

from panda-learning.

shingoxy avatar shingoxy commented on June 27, 2024

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

from panda-learning.

johnny46 avatar johnny46 commented on June 27, 2024

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

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

from panda-learning.

shingoxy avatar shingoxy commented on June 27, 2024

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

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

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

from panda-learning.

vivoosz avatar vivoosz commented on June 27, 2024

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

感谢!

from panda-learning.

zxminglj avatar zxminglj commented on June 27, 2024

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

from panda-learning.

18958092381 avatar 18958092381 commented on June 27, 2024

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

from panda-learning.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.