京东自动入会获取京豆

Overview

京东入会领京豆

要求

  1. 有一定的电脑知识 or 有耐心爱折腾
  2. 需要Chrome(推荐)Edge(Chromium)Firefox
  3. 操作系统需是Mac(本人没在m1上测试)Linux(在deepin上测试过)Windows

安装方法

脚本采用Selenium遍历京东入会有礼界面,由于遍历了20000+个店铺,可能所需要的时间比较长(视电脑情况30min-5h)

  1. 克隆到本地

    git clone https://github.com/AntonVanke/JDBrandMember.git
  2. 安装所需要的包

    pip3 install -r requirements.txt
  3. 下载对应的浏览器驱动放到项目的drivers文件夹下面

    1. chrome请访问chrome://version/查看浏览器的版本,然后去ChromeDriver Mirror (taobao.org)下载对应的版本/系统驱动
    2. edge请访问edge://version/查看浏览器的版本,Microsoft Edge - Webdriver (windows.net)下载
    3. Firefox请访问Releases · mozilla/geckodriver (github.com)下载
  4. 配置config.json

    {
        "thread": 6,  # 线程数, 推荐4-8线程
        "browserType": "Chrome",  # Chrome/Edge/Firefox
        "headless": true,  # 无头模式 请保持开启否则多线程情况下窗口比较多
        "binary": "",  # 可执行路径,如果驱动没有找到浏览器的话需要你手动配置
        "useUser": 0,  # 用户下标,默认是0(users[0]第一个用户)
        "users": []  # 用户列表可以通过 add_cookie.py 添加
    }
  5. 添加cookie

    请在项目目录下执行python3 add_cookie.py, 在打开的浏览器界面登录你的京东,此时你可以看到config.json已经有了你的用户信息(请不要随意泄露你的cookie

  6. 执行主程序

    在项目目录下执行python3 main.py,等待执行完毕即可,你可以访问项目下的logs/jdbm.log查看你的日志

LICENSE

MIT License

Copyright (c) 2021 Vanke Anton

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Comments
  • 报错:OSError: [WinError 193] %1 不是有效的 Win32 应用程序

    报错:OSError: [WinError 193] %1 不是有效的 Win32 应用程序

    2021-05-21 21:52:18 INFO 结束运行 Traceback (most recent call last): File "C:\Users\Yang\Desktop\JDBrandMember-main\main.py", line 391, in main() File "C:\Users\Yang\Desktop\JDBrandMember-main\main.py", line 341, in main add_cookie() File "C:\Users\Yang\Desktop\JDBrandMember-main\main.py", line 102, in add_cookie browser = get_browser(False) File "C:\Users\Yang\Desktop\JDBrandMember-main\main.py", line 89, in get_browser return webdriver.Chrome(executable_path=get_file_path("drivers/chromedriver"), desired_capabilities={}, File "C:\Users\Yang\AppData\Local\Programs\Python\Python39-32\lib\site-packages\selenium\webdriver\chrome\webdriver.py", line 73, in init self.service.start() File "C:\Users\Yang\AppData\Local\Programs\Python\Python39-32\lib\site-packages\selenium\webdriver\common\service.py", line 72, in start self.process = subprocess.Popen(cmd, env=self.env, File "C:\Users\Yang\AppData\Local\Programs\Python\Python39-32\lib\subprocess.py", line 951, in init self._execute_child(args, executable, preexec_fn, close_fds, File "C:\Users\Yang\AppData\Local\Programs\Python\Python39-32\lib\subprocess.py", line 1420, in _execute_child hp, ht, pid, tid = _winapi.CreateProcess(executable, args, OSError: [WinError 193] %1 不是有效的 Win32 应用程序。

    opened by lanyucomputer 27
  • ubuntu 下无法运行

    ubuntu 下无法运行

    按照攻略执行到 python3 main.py后产生报错 Traceback (most recent call last): File "/root/jd/ht/main.py", line 1, in import ctypes File "/usr/local/python3/lib/python3.9/ctypes/init.py", line 8, in from _ctypes import Union, Structure, Array ModuleNotFoundError: No module named '_ctypes'

    已经按照百度安装了libffi-devel python3 版本--Python 3.9.4 请问大神有解决的方法吗

    opened by winsonhet 12
  • termux终端可否实现跑脚本?

    termux终端可否实现跑脚本?

    大神,你好

        想尝试在termux上跑这个脚本,但失败了,可能是没有安装或者说没有正确识别google driver有关。错误如下:
    

    运行python3 main.py

    Traceback (most recent call last): File "/data/data/com.termux/files/usr/lib/python3.9/site-packages/selenium/webdriver/common/service.py", line 72, in start self.process = subprocess.Popen(cmd, env=self.env, File "/data/data/com.termux/files/usr/lib/python3.9/subprocess.py", line 951, in init self._execute_child(args, executable, preexec_fn, close_fds, File "/data/data/com.termux/files/usr/lib/python3.9/subprocess.py", line 1821, in _execute_child raise child_exception_type(errno_num, err_msg, err_filename) FileNotFoundError: [Errno 2] No such file or directory: 'drivers/chromedriver'

    During handling of the above exception, another exception occurred:

    Traceback (most recent call last): File "/data/data/com.termux/files/home/JDBrandMember/main.py", line 254, in browser = getBrowser(headless=False) File "/data/data/com.termux/files/home/JDBrandMember/main.py", line 224, in getBrowser _browser = webdriver.Chrome(executable_path="drivers/chromedriver", options=chrome_options) File "/data/data/com.termux/files/usr/lib/python3.9/site-packages/selenium/webdriver/chrome/webdriver.py", line 73, in init self.service.start() File "/data/data/com.termux/files/usr/lib/python3.9/site-packages/selenium/webdriver/common/service.py", line 81, in start raise WebDriverException( selenium.common.exceptions.WebDriverException: Message: 'chromedriver' executable needs to be in PATH. Please see https://sites.google.com/a/chromium.org/chromedriver/home

      因不便用电脑,想问下,有没有可能在终端里跑这个脚本,谢谢!
    
    opened by biewenwoshishui021 6
  • 为什么会报错,用提3.8和3.95版64位的,难道要用32位的PYTHON吗?我等下用32位试下,不行再来反馈

    为什么会报错,用提3.8和3.95版64位的,难道要用32位的PYTHON吗?我等下用32位试下,不行再来反馈

    2021-05-21 21:33:22 INFO 结束运行 Traceback (most recent call last): File "C:\Users\Yang\Desktop\JDBrandMember-main\main.py", line 391, in main() File "C:\Users\Yang\Desktop\JDBrandMember-main\main.py", line 341, in main add_cookie() File "C:\Users\Yang\Desktop\JDBrandMember-main\main.py", line 102, in add_cookie browser = get_browser(False) File "C:\Users\Yang\Desktop\JDBrandMember-main\main.py", line 89, in get_browser return webdriver.Chrome(executable_path=get_file_path("drivers/chromedriver"), desired_capabilities={}, File "C:\Users\Yang\AppData\Local\Programs\Python\Python39\lib\site-packages\selenium\webdriver\chrome\webdriver.py", line 73, in init self.service.start() File "C:\Users\Yang\AppData\Local\Programs\Python\Python39\lib\site-packages\selenium\webdriver\common\service.py", line 72, in start self.process = subprocess.Popen(cmd, env=self.env, File "C:\Users\Yang\AppData\Local\Programs\Python\Python39\lib\subprocess.py", line 951, in init self._execute_child(args, executable, preexec_fn, close_fds, File "C:\Users\Yang\AppData\Local\Programs\Python\Python39\lib\subprocess.py", line 1420, in _execute_child hp, ht, pid, tid = _winapi.CreateProcess(executable, args, OSError: [WinError 193] %1 不是有效的 Win32 应用程序。

    opened by lanyucomputer 3
  • 大佬能不能看一下这是什么问题

    大佬能不能看一下这是什么问题

    File "E:\JD\main.py", line 89, in get_browser return webdriver.Chrome(executable_path=get_file_path("drivers/chromedriver"), desired_capabilities={}, File "D:\python\lib\site-packages\selenium\webdriver\chrome\webdriver.py", line 76, in init RemoteWebDriver.init( File "D:\python\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 157, in init self.start_session(capabilities, browser_profile) File "D:\python\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 252, in start_session response = self.execute(Command.NEW_SESSION, parameters) File "D:\python\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 321, in execute self.error_handler.check_response(response) File "D:\python\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 242, in check_response raise exception_class(message, screen, stacktrace) selenium.common.exceptions.WebDriverException: Message: unknown error: cannot find Chrome binary

    opened by RPZ1211 3
  • 运行出错

    运行出错

    运行出现以下错误,求教大佬如何解决,使用的平台是win10,Google Chrome 版本 90.0.4430.72(正式版本) (64 位),用的最新版京东入会有礼刷京豆0.3(附打包程序) DevTools listening on ws://127.0.0.1:9254/devtools/browser/88214b30-de5f-4a44-be75-3ad51055359f [14228:9528:0420/041210.575:ERROR:ssl_client_socket_impl.cc(947)] handshake failed; returned -1, SSL error code 1, net_error -101 [14228:9528:0420/041210.684:ERROR:ssl_client_socket_impl.cc(947)] handshake failed; returned -1, SSL error code 1, net_error -101 2021-04-20 04:12:15 INFO 登录成功 用户名:京豆数: [14772:7852:0420/041216.733:ERROR:device_event_log_impl.cc(214)] [04:12:16.734] Bluetooth: bluetooth_adapter_winrt.cc:1072 Getting Default Adapter failed. [15200:14480:0420/041404.804:ERROR:gpu_init.cc(426)] Passthrough is not supported, GL is disabled

    opened by bbilyvm 3
Releases(v21.05.31)
  • v21.05.31(May 31, 2021)

  • v21.05.30(May 30, 2021)

  • v21.05.15(May 14, 2021)

  • v21.04.30(Apr 30, 2021)

    https://github.com/AntonVanke/JDBrandMember/issues/19#issuecomment-829754120 https://github.com/AntonVanke/JDBrandMember/issues/19#issuecomment-830176294 https://github.com/AntonVanke/JDBrandMember/issues/21#issuecomment-829757868 https://github.com/AntonVanke/JDBrandMember/issues/15


    1. 修改了进度条显示
    2. 更新了 shopid.txt
    3. 修复了去重的方式
    4. 重新遍历了近期(2021年04月30日)入会送京豆的网站

    注意:

    1. config.json包含你的用户信息
    2. 如果关闭程序后CPU占用率依旧很高,请执行stop.bat如果你正在使用浏览器,执行前请保存好你的浏览器内容。
    3. 这是一个测试版本
    4. 其它请查看readme.md

    https://github.com/AntonVanke/JDBrandMember/blob/main/README.md#%E5%AE%89%E8%A3%85%E6%96%B9%E6%B3%95

    这个项目是我为了练习数据爬取而创建的,可能会有各式各样的错误,如果有什么问题的话欢迎反馈。
    Source code(tar.gz)
    Source code(zip)
    21_04_30_Windows_10_Chrome.zip(16.34 MB)
  • v21.04.24-beta(Apr 24, 2021)

    更新了以下内容

    1. 加快了遍历速度,降低cpu占用率
    2. 独立了添加cookie的程序add_cookie.exe,可以添加多用户(暂时需在config手动选择)
    3. 重新遍历了近期(2021年04月23日)入会送京豆的网站

    使用了Pyinstaller打包了Windows平台的应用程序,解压缩首先运行add_cookie.exe添加用户,再运行main.exe开始。

    默认的Chrome驱动版本是90.0.4430.85,其它版本的Chrome请自行下载;其它版本的浏览器请自行下载驱动并配置config.json

    注意:

    1. config.json包含你的用户信息
    2. 如果关闭程序后CPU占用率依旧很高,请执行stop.bat如果你正在使用浏览器,执行前请保存好你的浏览器内容。
    3. 这是一个测试版本
    4. 其它请查看readme.md
    这个项目是我为了练习数据爬取而创建的,可能会有各式各样的错误,如果有什么问题的话欢迎反馈。
    Source code(tar.gz)
    Source code(zip)
    21_04_24_Windows_10_Chrome.zip(22.01 MB)
  • v21.04.17(Apr 17, 2021)

    更新了以下内容

    • 采用多线程的方式,更快速的遍历(能在一个小时遍历完全)
    • 重新爬取了京东的店铺数据,将50万个店铺精简到25878
    • 重新遍历了近期(2021年04月17日)入会送京豆的网站,存储在url.txt下,以供快速刷分

    另外使用了Pyinstaller打包了三个平台的应用程序,解压缩运行即可

    注意:

    Linux 可能会遇到找不到chrome的情况,需要配置目录

    请在电脑上安装对应版本的Chrome浏览器

    pyinstaller打包的应用程序可能会有各式各样的问题,建议还是直接运行Python代码

    这个项目是我为了练习数据爬取而创建的,可能会有各式各样的错误,因为我是初学者,如果有什么问题的话可以联系我。
    Source code(tar.gz)
    Source code(zip)
    21_04_17_Linux_Chrome.zip(12.25 MB)
    21_04_17_Mac_86_64_Chrome.zip(15.87 MB)
    21_04_17_Windows_10_Chrome.zip(13.15 MB)
  • v21.04.04(Apr 4, 2021)

  • v21.04.02(Apr 2, 2021)

    Source code(tar.gz)
    Source code(zip)
Owner
Vanke Anton
Vanke Anton