-
Notifications
You must be signed in to change notification settings - Fork 80
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
init
- Loading branch information
0 parents
commit 28c0902
Showing
25 changed files
with
1,782 additions
and
0 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
[config] | ||
# eid, fp参数必须填写,具体请参考 wiki-常见问题 | ||
# 随意填写可能导致订单无法提交等问题 | ||
eid = "" | ||
fp = "" | ||
# cookie现在不需要填写了 | ||
# cookies_String = "" | ||
|
||
# 商品id | ||
# 已经是茅台的sku_id了 | ||
sku_id = | ||
# 抢购数量 | ||
seckill_num = 1 | ||
# 设定时间 | ||
# 修改成几点几分几秒几毫秒 以下时间根据jd抢购时间修改 | ||
buy_time = 23:59:59.500 | ||
# 每天的最后购买时间 | ||
last_purchase_time = 00:00:03.000 | ||
# 默认UA | ||
DEFAULT_USER_AGENT = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36" | ||
# 是否使用随机 useragent,默认为 false | ||
random_useragent = false | ||
|
||
[account] | ||
# 支付密码 | ||
# 如果你的账户中有可用的京券(注意不是东券)或 在上次购买订单中使用了京豆, | ||
# 那么京东可能会在下单时自动选择京券支付 或 自动勾选京豆支付。 | ||
# 此时下单会要求输入六位数字的支付密码。请在下方配置你的支付密码,如 123456 。 | ||
# 如果没有上述情况,下方请留空。 | ||
payment_pwd = "" | ||
|
||
[messenger] | ||
# 使用了Server酱的推送服务 | ||
# 如果想开启下单成功后消息推送,则将 enable 设置为 true,默认为 false 不开启推送 | ||
# 开启消息推送必须填入 sckey,如何获取请参考 http://sc.ftqq.com/3.version。感谢Server酱~ | ||
enable = false | ||
sckey = |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# !/usr/bin/env python | ||
# -*- coding: utf-8 -*- | ||
|
||
""" | ||
Created on 2021/01/02 21:45 | ||
""" |
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#!/usr/bin/env python | ||
# -*- encoding=utf8 -*- | ||
|
||
|
||
class SKException(Exception): | ||
|
||
def __init__(self, message): | ||
super().__init__(message) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# !/usr/bin/env python | ||
# -*- coding: utf-8 -*- | ||
|
||
""" | ||
Created on 2021/01/02 21:39 | ||
""" |
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
import json | ||
import random | ||
import requests | ||
import os | ||
import time | ||
|
||
from maotai.config import global_config | ||
|
||
USER_AGENTS = [ | ||
"Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2228.0 Safari/537.36", | ||
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2227.1 Safari/537.36", | ||
"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2227.0 Safari/537.36", | ||
"Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2227.0 Safari/537.36", | ||
"Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2226.0 Safari/537.36", | ||
"Mozilla/5.0 (Windows NT 6.4; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2225.0 Safari/537.36", | ||
"Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2225.0 Safari/537.36", | ||
"Mozilla/5.0 (Windows NT 5.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2224.3 Safari/537.36", | ||
"Mozilla/5.0 (Windows NT 10.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/40.0.2214.93 Safari/537.36", | ||
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/37.0.2062.124 Safari/537.36", | ||
"Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/37.0.2049.0 Safari/537.36", | ||
"Mozilla/5.0 (Windows NT 4.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/37.0.2049.0 Safari/537.36", | ||
"Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/36.0.1985.67 Safari/537.36", | ||
"Mozilla/5.0 (Windows NT 5.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/36.0.1985.67 Safari/537.36", | ||
"Mozilla/5.0 (X11; OpenBSD i386) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/36.0.1985.125 Safari/537.36", | ||
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/36.0.1944.0 Safari/537.36", | ||
"Mozilla/5.0 (Windows NT 5.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/35.0.3319.102 Safari/537.36", | ||
"Mozilla/5.0 (Windows NT 5.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/35.0.2309.372 Safari/537.36", | ||
"Mozilla/5.0 (Windows NT 5.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/35.0.2117.157 Safari/537.36", | ||
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/35.0.1916.47 Safari/537.36", | ||
"Mozilla/5.0 (Windows NT 5.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/34.0.1866.237 Safari/537.36", | ||
"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/34.0.1847.137 Safari/4E423F", | ||
"Mozilla/5.0 (Windows NT 5.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/34.0.1847.116 Safari/537.36 Mozilla/5.0 (iPad; U; CPU OS 3_2 like Mac OS X; en-us) AppleWebKit/531.21.10 (KHTML, like Gecko) Version/4.0.4 Mobile/7B334b Safari/531.21.10", | ||
"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/33.0.1750.517 Safari/537.36", | ||
"Mozilla/5.0 (Windows NT 6.2; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/32.0.1667.0 Safari/537.36", | ||
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/32.0.1664.3 Safari/537.36", | ||
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/32.0.1664.3 Safari/537.36", | ||
"Mozilla/5.0 (Windows NT 5.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/31.0.1650.16 Safari/537.36", | ||
"Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/31.0.1623.0 Safari/537.36", | ||
"Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/30.0.1599.17 Safari/537.36", | ||
"Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/29.0.1547.62 Safari/537.36", | ||
"Mozilla/5.0 (X11; CrOS i686 4319.74.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/29.0.1547.57 Safari/537.36", | ||
"Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/29.0.1547.2 Safari/537.36", | ||
"Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/28.0.1468.0 Safari/537.36", | ||
"Mozilla/5.0 (Windows NT 6.2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/28.0.1467.0 Safari/537.36", | ||
"Mozilla/5.0 (Windows NT 6.2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/28.0.1464.0 Safari/537.36", | ||
"Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/27.0.1500.55 Safari/537.36", | ||
"Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/27.0.1453.93 Safari/537.36", | ||
"Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/27.0.1453.93 Safari/537.36", | ||
"Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/27.0.1453.93 Safari/537.36", | ||
"Mozilla/5.0 (Windows NT 5.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/27.0.1453.93 Safari/537.36", | ||
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/27.0.1453.93 Safari/537.36", | ||
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/27.0.1453.93 Safari/537.36", | ||
"Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/27.0.1453.90 Safari/537.36", | ||
"Mozilla/5.0 (X11; NetBSD) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/27.0.1453.116 Safari/537.36", | ||
"Mozilla/5.0 (X11; CrOS i686 3912.101.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/27.0.1453.116 Safari/537.36", | ||
"Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.17 (KHTML, like Gecko) Chrome/24.0.1312.60 Safari/537.17", | ||
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_2) AppleWebKit/537.17 (KHTML, like Gecko) Chrome/24.0.1309.0 Safari/537.17", | ||
"Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.15 (KHTML, like Gecko) Chrome/24.0.1295.0 Safari/537.15", | ||
"Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.14 (KHTML, like Gecko) Chrome/24.0.1292.0 Safari/537.14" | ||
] | ||
|
||
|
||
def parse_json(s): | ||
begin = s.find('{') | ||
end = s.rfind('}') + 1 | ||
return json.loads(s[begin:end]) | ||
|
||
|
||
def get_random_useragent(): | ||
"""生成随机的UserAgent | ||
:return: UserAgent字符串 | ||
""" | ||
return random.choice(USER_AGENTS) | ||
|
||
|
||
def wait_some_time(): | ||
time.sleep(random.randint(100, 300) / 1000) | ||
|
||
|
||
def send_wechat(message): | ||
"""推送信息到微信""" | ||
url = 'http://sc.ftqq.com/{}.send'.format(global_config.getRaw('messenger', 'sckey')) | ||
payload = { | ||
"text": '抢购结果', | ||
"desp": message | ||
} | ||
headers = { | ||
'User-Agent': global_config.getRaw('config', 'DEFAULT_USER_AGENT') | ||
} | ||
requests.get(url, params=payload, headers=headers) | ||
|
||
|
||
def response_status(resp): | ||
if resp.status_code != requests.codes.OK: | ||
print('Status: %u, Url: %s' % (resp.status_code, resp.url)) | ||
return False | ||
return True | ||
|
||
|
||
def open_image(image_file): | ||
if os.name == "nt": | ||
os.system('start ' + image_file) # for Windows | ||
else: | ||
if os.uname()[0] == "Linux": | ||
if "deepin" in os.uname()[2]: | ||
os.system("deepin-image-viewer " + image_file) # for deepin | ||
else: | ||
os.system("eog " + image_file) # for Linux | ||
else: | ||
os.system("open " + image_file) # for Mac | ||
|
||
|
||
def save_image(resp, image_file): | ||
with open(image_file, 'wb') as f: | ||
for chunk in resp.iter_content(chunk_size=1024): | ||
f.write(chunk) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import sys | ||
|
||
from maotai.jd_spider_requests import JdSeckill | ||
|
||
if __name__ == '__main__': | ||
a = """ | ||
oooo oooooooooo. .oooooo..o oooo o8o oooo oooo | ||
`888 `888' `Y8b d8P' `Y8 `888 `"' `888 `888 | ||
888 888 888 Y88bo. .ooooo. .ooooo. 888 oooo oooo 888 888 | ||
888 888 888 `"Y8888o. d88' `88b d88' `"Y8 888 .8P' `888 888 888 | ||
888 888 888 8888888 `"Y88b 888ooo888 888 888888. 888 888 888 | ||
888 888 d88' oo .d8P 888 .o 888 .o8 888 `88b. 888 888 888 | ||
.o. 88P o888bood8P' 8""88888P' `Y8bod8P' `Y8bod8P' o888o o888o o888o o888o o888o | ||
`Y888P | ||
功能列表: | ||
1.预约商品 | ||
2.秒杀抢购商品 | ||
""" | ||
print(a) | ||
|
||
jd_seckill = JdSeckill() | ||
choice_function = input('请选择:') | ||
if choice_function == '1': | ||
jd_seckill.reserve() | ||
elif choice_function == '2': | ||
jd_seckill.seckill_by_proc_pool() | ||
else: | ||
print('没有此功能') | ||
sys.exit(1) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# !/usr/bin/env python | ||
# -*- coding: utf-8 -*- | ||
|
||
""" | ||
Created on 2021/01/02 21:39 | ||
""" |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import logging | ||
import logging.handlers | ||
|
||
''' | ||
日志模块 | ||
''' | ||
LOG_FILENAME = '../jd_seckill.log' | ||
logger = logging.getLogger() | ||
|
||
|
||
def set_logger(): | ||
logger.setLevel(logging.INFO) | ||
formatter = logging.Formatter('%(asctime)s - %(process)d-%(threadName)s - ' | ||
'%(pathname)s[line:%(lineno)d] - %(levelname)s: %(message)s') | ||
console_handler = logging.StreamHandler() | ||
console_handler.setFormatter(formatter) | ||
logger.addHandler(console_handler) | ||
file_handler = logging.handlers.RotatingFileHandler( | ||
LOG_FILENAME, maxBytes=10485760, backupCount=5, encoding="utf-8") | ||
file_handler.setFormatter(formatter) | ||
logger.addHandler(file_handler) | ||
|
||
|
||
set_logger() |
Oops, something went wrong.