Last active
July 20, 2017 01:08
-
-
Save sonya75/6179c33789d0fee0d5bef8f60ccaa693 to your computer and use it in GitHub Desktop.
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
import requests | |
import sys | |
from requests.packages.urllib3.exceptions import InsecureRequestWarning | |
requests.packages.urllib3.disable_warnings(InsecureRequestWarning) | |
FIRSTNAME="John" | |
LASTNAME="Doe" | |
def f(sess,username,password): | |
global FIRSTNAME,LASTNAME | |
sess.get("http://www.nike.com/us/en_us") | |
e=sess.post("https://unite.nike.com/loginWithSetCookie?appVersion=287&experienceVersion=249&uxid=com.nike.commerce.nikedotcom.web&locale=en_US&backendEnvironment=identity&browser=Google%20Inc.&os=undefined&mobile=false&native=false",data='{"username":"'+username+'","password":"'+password+'","keepMeLoggedIn":true,"client_id":"HlHa2Cje3ctlaOqnxvgZXNaAs7T9nAuH","ux_id":"com.nike.commerce.nikedotcom.web","grant_type":"password"}',headers={"User-Agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.133 Safari/537.36","X-Requested-With":"XMLHttpRequest","Content-Type":"text/plain","Origin":"http://www.nike.com","Referer":"http://www.nike.com/us/en_us","Accept":"*/*","Accept-Encoding":"gzip, deflate, br","Accept-Language":"en-US,en;q=0.8,ms;q=0.6"},verify=False) | |
e.raise_for_status() | |
userid=e.json()['user_id'] | |
e=sess.put("https://www.nike.com/profile/services/users/{0}".format(userid),json={"firstName":FIRSTNAME,"lastName":LASTNAME},verify=False) | |
e.raise_for_status() | |
allnames=open(sys.argv[1],'r').read().replace('\r','\n').split('\n') | |
allnames=[q.strip() for q in allnames if q.strip()!=''] | |
sess=requests.session() | |
for q in allnames: | |
sess.cookies.clear() | |
sess.cookies['nike-locale']='us/en_us' | |
try: | |
f(sess,q.split(':')[0],q.split(':')[1]) | |
print "Success "+q | |
except Exception as e: | |
print e | |
print "Failed "+q |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment