Skip to content

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
ganlinhao committed Jun 10, 2020
0 parents commit bc3f7d2
Show file tree
Hide file tree
Showing 10 changed files with 925 additions and 0 deletions.
46 changes: 46 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Jd_mask[如果可以点下右上角的star给颗小星星呗谢谢]
# 因为最近忙于换工作的原因,此代码不会再更新.等后面618之类的活动此代码会再更新.而且一直没来回复issues,各位大佬不好意思.告辞!

##### 此tool只单独支持预约-抢购-成功后直接提交订单的商品.[口罩],只提供学习参考用途.!

##### 此代码基于原作者https://github.com/tychxn/jd-assistan 进行修改合并

##### 非常感谢原作者https://github.com/tychxn/jd-assistant 提供的代码
[![star, issue](https://img.shields.io/badge/star%2C%20issue-welcome-brightgreen.svg)](https://github.com/zhou-xiaojun/jd_mask)

## 主要功能

- 登陆京东商城([www.jd.com](http://www.jd.com/)
- cookies登录 (需要自己手动获取)
- 预约商品
- 定时自动预约
- 秒杀预约后等待抢购的商品
- 定时开始自动抢购

## 运行环境

- [Python 3](https://www.python.org/)

## 第三方库

- [Requests](http://docs.python-requests.org/en/master/)

## 使用教程

程序主入口在 `main.py`

在config.ini文件填入config里面对应的内容
eid,和fp找个普通商品随便下单,然后抓包就能看到,这两个值可以填固定的
cookies_string,sku_id,DEFAULT_USER_AGENT(和cookie获取同一个地方就会看到.直接复制进去就可以了),以上都是必填的.

启动时按照提示操作输入需要的功能即可

## 更新记录

- 【2020.02.24】新增微信推送,去除了冗余代码,进行模块化处理.

## 备注

- 关于时间的设置,我测试成功的2次都是设置了整点获取抢购连接失败一次后1s再获取成功,后面试过测试了2次0.6s的反而不行,会出现请求获取订单参数超时导致报错.网络好的可以试一下设置0.5s左右的误差
- 本来时间不足,加上一天只能测试一次.而且网络不稳定.只抢购成功2次.而且都是数量1,我记得有几个口罩不能设置数量,只能抢购1个,所以要注意这点.
- 代码在`macOS`中编写,如果在其他平台上运行出行问题,欢迎提issue。
37 changes: 37 additions & 0 deletions config.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
[config]
# eid, fp参数必须填写,具体请参考 wiki-常见问题
# 随意填写可能导致订单无法提交等问题
eid = "XMKWG35OFYBQN3C5JYD7J4FNOWNXSGBIZNIKBUVVQEMJW6766KKTNYZD43U3Y7VCWA73EEWJRCOTKU7QVG3WKUNNQA"
fp = "2ea01d1acb70ab62c8607786d7273205"
# cookie
cookies_String ="__jdu=1586273021865136663377; shshshfpa=1d79a82c-037d-8e4e-47cb-e35d2f9e66ae-1586273130; shshshfpb=ypTYIktPFs89QK5nxn8nGIw%3D%3D; unpl=V2_ZzNtbRYHRxZ1X0EBfktdDGIDEFoSUhccJlxHXHNOWAQ3V0YJclRCFnQUR1BnGlQUZwQZWEdcQRBFCEdkeB5fA2AFEFlBZxpFK0oYEDlNDEY1WnxdRF9DFnEAR1B9KWwGZzMSXHJXRxxyC0BWehpcDGAHEl9FUEQXdw5AZEsebDVXARpZR1NHJXQ4R2Q5TQAFbgUQXA9XRxxyC0BWehpcDGAHEl9FUEQXdw5AZHopXw%3d%3d; __jdv=76161171|haosou-search|t_262767352_haosousearch|cpc|1791259057_0_ea521f6d4c084136a4e8be099f50aeee|1590741875314; user-key=e7b2ce43-c8ea-498b-aa14-1d72ba811c3b; cn=14; ipLocation=%u5e7f%u897f; pinId=RKLv5CxPY3leYrbiqjD_zrV9-x-f3wj7; pin=243864730-341142; unick=%E8%9B%8B%E9%BB%84%E9%85%B1%E5%95%8A%E5%AE%9D%E5%AE%9D; ceshi3.com=201; _tp=G9fKS8tOq9vYWtFzoQL6S58tnu1J7NXnsaIj9rKmcI8%3D; _pst=243864730-341142; areaId=20; ipLoc-djd=20-1761-25188-0; TrackID=164w4EaXgdVB8pmGgufMvZxffVg93QU3DR1qoyUmb9AbFnt_XMZ4cCggrBVqxQbwH6Sq6wvHiQ0tfbjTM9Mez0AhaI61woZr-qrMvbKOsZZT67SVvoLrkZfKMAeezI4Xx; thor=721925D5F86146929EDB9E937057356EBD65E8075AF346CDA6DFD00A839FDAAE5B800AD469815047B419498006934452FA72C6513EDDC62E79BDBB5883B46087391FF3C8EE2E5C2246FA96BF54ADD140DF2918C35D29DCE2BE90D0FEBEE2263DEEE9DEE73277CFE2BC97AA575462FDE847C8209285C17235C0566829976AABB1BFDA92428C8EA169ADB615E06CB05003B543B48B7BD5F744BDED08A66B10D5D3; __jda=122270672.1586273021865136663377.1586273022.1591320625.1591667887.11; __jdc=122270672; 3AB9D23F7A4B3C9B=XMKWG35OFYBQN3C5JYD7J4FNOWNXSGBIZNIKBUVVQEMJW6766KKTNYZD43U3Y7VCWA73EEWJRCOTKU7QVG3WKUNNQA; __jdb=122270672.8.1586273021865136663377|11.1591667887; shshshfp=4d12604ada2ade89734b633f704fe848; shshshsID=b512228e41868a27ab8199eb73396a90_4_1591667938758"

#cookies_String = "__jdu=1586273021865136663377; shshshfpa=1d79a82c-037d-8e4e-47cb-e35d2f9e66ae-1586273130; shshshfpb=ypTYIktPFs89QK5nxn8nGIw%3D%3D; ceshi3.com=201; unpl=V2_ZzNtbRYHRxZ1X0EBfktdDGIDEFoSUhccJlxHXHNOWAQ3V0YJclRCFnQUR1BnGlQUZwQZWEdcQRBFCEdkeB5fA2AFEFlBZxpFK0oYEDlNDEY1WnxdRF9DFnEAR1B9KWwGZzMSXHJXRxxyC0BWehpcDGAHEl9FUEQXdw5AZEsebDVXARpZR1NHJXQ4R2Q5TQAFbgUQXA9XRxxyC0BWehpcDGAHEl9FUEQXdw5AZHopXw%3d%3d; __jdv=76161171|haosou-search|t_262767352_haosousearch|cpc|1791259057_0_ea521f6d4c084136a4e8be099f50aeee|1590741875314; areaId=20; user-key=e7b2ce43-c8ea-498b-aa14-1d72ba811c3b; TrackID=14zpGGB-OpJ4mkipibzlKLH_cntpvRWi1YuLUjQQ9V-kkhdgGNzIYgnDptMlqfJhNhu8ozJ_qMXppTXszcg6uSBKf3xsYTd9LGMPVWn_V3mfk98AjllQ77oNoZNf0vk_n; pinId=tnz4f2JFgMgyIVQ1is9ieg; pin=275466402_m; unick=%E4%B8%8D%E6%83%B3%E8%B7%91%E6%AD%A5%E7%9A%84%E5%B9%B2%E9%94%85%E9%94%85; _tp=hbuicMy40IDnjEA3yKCYJg%3D%3D; _pst=275466402_m; __jda=122270672.1586273021865136663377.1586273022.1590741875.1590853863.6; __jdc=122270672; shshshfp=4502485e8b520f53be89fe44a27717ee; 3AB9D23F7A4B3C9B=XMKWG35OFYBQN3C5JYD7J4FNOWNXSGBIZNIKBUVVQEMJW6766KKTNYZD43U3Y7VCWA73EEWJRCOTKU7QVG3WKUNNQA; cn=14; ipLoc-djd=20-1761-25188-51466.2052701265; ipLocation=%u5e7f%u897f; __tak=c94559a7e3893645ee7f9f3ba3af391b4381d8e935b4895cf5f4df48e014c4aca54c30a40df88a95e670fcf3ef153823cfc92c013e7e892133119c9f79811f1b9303c52b4dffffebb6b145cbe13fc0e0; thor=A3006E40DFDA6A23E9353F8A5BE5D7B526D907891A33D2D63A28B4F6F19DC6F67E8BAA1251F8FC51DA54936D111277AEF79F42D5BBCA8C7F01068EA42B4B681CF3D78B4CB73DF9E870791980E609BABE4426FF4EF4089405842C640217A10FEC30256F6BC66C63C67D595F08AE093A375782F916DE74D980FE9E18720F2D5987B03269FB13DC923CCCEC51A5FD7155FD; shshshsID=b122acc455c4e500fe48a45f327cbeac_17_1590855792368; __jdb=122270672.25.1586273021865136663377|6.1590853863"
# 商品id
sku_id = 100012043978
# 设定时间 # 2020-02-24 10:00:00.100000
buy_time = 2020-06-09 10:00:00.150
# 默认UA
DEFAULT_USER_AGENT = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.138 Safari/537.36"
# 是否使用随机 useragent,默认为 false
random_useragent = false

#2020-06-09 09:59:53,330 INFO: 用户:蛋黄酱啊宝宝
#2020-06-09 09:59:54,072 INFO: 商品名称:【茅台白酒】茅台 飞天 酱香型白酒 53度 500ml【行情 报价 价格 评测】-京东
#2020-06-09 09:59:54,073 INFO: 正在等待到达设定时间:2020-06-09 10:00:00.150000
#2020-06-09 10:00:00,617 INFO: 时间到达,开始执行……
#2020-06-09 10:00:01,958 INFO: 抢购链接获取成功: https://marathon.jd.com/captcha.html?skuId=100012043978&sn=ce68546e7bd7529a57853feea8256ffc&from=pc
#2020-06-09 10:00:01,960 INFO: 访问商品的抢购连接...
#2020-06-09 10:00:02,376 INFO: 访问抢购订单结算页面...
#2020-06-09 10:00:02,698 INFO: 生成提交抢购订单所需参数...
#2020-06-09 10:00:02,699 INFO: 获取秒杀初始化信息...
#2020-06-09 10:00:03,128 INFO: 提交抢购订单...
#2020-06-09 10:00:03,395 INFO: 抢购失败,返回信息:{'errorMessage': '很遗憾没有抢到,再接再厉哦。', 'orderId': 0, 'resultCode': 90008, 'skuId': 0, 'success': False}


[messenger]
# 使用了Server酱的推送服务
# 如果想开启下单成功后消息推送,则将 enable 设置为 true,默认为 false 不开启推送
# 开启消息推送必须填入 sckey,如何获取请参考 http://sc.ftqq.com/3.version。感谢Server酱~
enable = false
sckey =
22 changes: 22 additions & 0 deletions config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import os
import configparser


class Config(object):
def __init__(self, config_file='config.ini'):
self._path = os.path.join(os.getcwd(), config_file)
if not os.path.exists(self._path):
raise FileNotFoundError("No such file: config.ini")
self._config = configparser.ConfigParser()
self._config.read(self._path, encoding='utf-8-sig')
self._configRaw = configparser.RawConfigParser()
self._configRaw.read(self._path, encoding='utf-8-sig')

def get(self, section, name):
return self._config.get(section, name)

def getRaw(self, section, name):
return self._configRaw.get(section, name)


global_config = Config()
Loading

0 comments on commit bc3f7d2

Please sign in to comment.