├── setting.txt ├── README.md └── trainNIKE.py /setting.txt: -------------------------------------------------------------------------------- 1 | time:20 2 | 这里是账号 这里是密码 3 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Nike官网养号机 2 | 用于自动化日常浏览nike官网的商品,使该账号活跃,以增加中奖机率。 3 | # 使用方法 4 | 1.在[release](https://github.com/stvea/trainNikeAccount/releases)下载打包好的程序; 5 | 2.使编辑setting.txt中的数据,第一行为每件商品浏览时间,剩余行数按照:账号 密码的形式输入; 6 | 3.确保你的Chrome更新至最新版; 7 | 4.双击运行 8 | -------------------------------------------------------------------------------- /trainNIKE.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | import time 3 | import random 4 | from selenium import webdriver 5 | from selenium.webdriver.common.by import By 6 | from selenium.webdriver.support.ui import WebDriverWait 7 | from selenium.webdriver.support import expected_conditions as EC 8 | from selenium.webdriver.common.keys import Keys 9 | from selenium.webdriver.common.action_chains import ActionChains 10 | 11 | 12 | def getAccounts(): 13 | accounts = [] 14 | file = open("setting.txt",'r') 15 | line = file.readline() 16 | line = line[:-1] 17 | delay_time = float(line.split(':')[1]) 18 | while line: 19 | line = file.readline() 20 | line = line[:-1] 21 | if line != '': 22 | accounts.append(line.split(' ')) 23 | print '[STVEAtrainNike]>Get '+str(len(accounts))+' accounts' 24 | return delay_time,accounts 25 | 26 | 27 | def printRights(): 28 | print " ,----, " 29 | print " ,/ .`| " 30 | print " .--.--. ,` .' : ,---,. ,---, " 31 | print " ,---, / / '. ; ; / ,---. ,' .' | ' .' \ " 32 | print ",---.'| | : /`. /.'___,/ ,' /__./|,---.' | / ; '. " 33 | print "| | : ; | |--` | : | ,---.; ; || | .': : \ " 34 | print ": : : .--,| : ;_ ; |.'; ;/___/ \ | |: : |-,: | /\ \ " 35 | print ": |,-. /_ ./| \ \ `.`----' | |\ ; \ ' |: | ;/|| : ' ;. : " 36 | print "| : ' | , ' , ' : `----. \ ' : ; \ \ \: || : .'| | ;/ \ \ " 37 | print "| | / :/___/ \: | __ \ \ | | | ' ; \ ' .| | |-,' : | \ \ ,' " 38 | print "' : |: | . \ ' | / /`--' / ' : | \ \ '' : ;/|| | ' '--' " 39 | print "| | '/ : \ ; :'--'. / ; |.' \ ` ;| | \| : : " 40 | print "| : | \ \ ; `--'---' '---' : \ || : .'| | ,' " 41 | print "/ \ / : \ \ '---'' | | ,' `--'' " 42 | print "`-'----' \ ' ; `----' " 43 | print " `--` " 44 | print "#################################################################################" 45 | print "" 46 | print "Please fill in your account info and browsing time for each item in setting.txt" 47 | print "More in STVEA.cn" 48 | print "" 49 | print "#################################################################################" 50 | # print "please input username:" 51 | # username = raw_input() 52 | # print "please input password:" 53 | # password = raw_input() 54 | 55 | printRights() 56 | delay_time,accounts = getAccounts() 57 | for accounts_num in range(len(accounts)): 58 | 59 | username = accounts[accounts_num][0] 60 | password = accounts[accounts_num][1] 61 | isEmail = not username.isdigit() 62 | 63 | chrome_options = webdriver.ChromeOptions() 64 | chrome_options.add_argument('--headless') 65 | chrome_options.add_argument('--log-level=2') 66 | prefs = {"profile.managed_default_content_settings.images":2} 67 | chrome_options.add_experimental_option("prefs",prefs) 68 | driver = webdriver.Chrome(chrome_options=chrome_options,executable_path='chromedriver.exe') 69 | driver.get("https://store.nike.com/cn/zh_cn/pw/mens-shoes/7puZoi3") 70 | 71 | login_href = driver.find_element_by_css_selector("[class='js-rootItem js-navItem']") 72 | login_href.click() 73 | 74 | if isEmail: 75 | print "[STVEAtrainNike]>A new account username:"+username+" using Email" 76 | driver.find_element_by_link_text('使用电子邮件登录。').click() 77 | login_username = "emailAddress" 78 | else: 79 | print "[STVEAtrainNike]>A new account username:"+username+" using Mobile" 80 | login_username = "verifyMobileNumber" 81 | 82 | driver.find_element_by_name(login_username).send_keys(username) 83 | driver.find_element_by_name("password").send_keys(password) 84 | driver.find_element_by_css_selector("[value='登录']").click() 85 | 86 | time.sleep(10) 87 | 88 | new_shoes = driver.find_elements_by_css_selector("[class='grid-item-image-wrapper sprite-sheet sprite-index-0']") 89 | random.shuffle(new_shoes) 90 | print "[STVEAtrainNike]>Have "+str(len(new_shoes))+" items." 91 | for i in range(len(new_shoes)): 92 | href = new_shoes[i].find_element_by_tag_name('a').get_attribute("href") 93 | js='window.open("'+href+'");' 94 | driver.execute_script(js) 95 | windows = driver.window_handles 96 | driver.switch_to.window(windows[1]) 97 | print username+">Browse shoes:["+driver.title.replace(u'\xa0', u'')+"]" 98 | time.sleep(delay_time) 99 | driver.close() 100 | driver.switch_to.window(windows[0]) 101 | 102 | driver.quite() --------------------------------------------------------------------------------