Created
July 20, 2017 21:31
-
-
Save footcarts/8ead021cd0cf6bb5333a30c238ab2b37 to your computer and use it in GitHub Desktop.
scrape_naked.py
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 json | |
import argparse | |
def run(start, end): | |
headers = { | |
'origin': 'https://www.nakedcph.com', | |
'accept-encoding': 'gzip, deflate, br', | |
'x-requested-with': 'XMLHttpRequest', | |
'accept-language': 'en-US,en;q=0.8', | |
'content-type': 'application/x-www-form-urlencoded; charset=UTF-8', | |
'accept': '*/*', | |
'referer': 'https://www.nakedcph.com/puma-extra-butter-x-puma-clyde-362320-001/p/5383', | |
'authority': 'www.nakedcph.com', | |
} | |
i = start | |
while (i <= end): | |
s = requests.session() | |
data = [ | |
('_AntiCsrfToken', 'ebefd5e7a22842219e62c63af7557a2'), | |
('id', i), | |
] | |
r= s.post('https://www.nakedcph.com/cart/add', headers=headers, data=data) | |
c= json.loads(r.text) | |
try: | |
print (str(i)+ " : " + c['Response']['Items'][0]['Description']) | |
except: | |
print str(i)+ " : " + r.text | |
i = i + 1 | |
if __name__ == '__main__': | |
parser = argparse.ArgumentParser(description='scraper') | |
parser.add_argument('-s', '--start', required=True, | |
type=int, | |
help="start pid") | |
parser.add_argument('-e', '--end', required=True, | |
type=int, | |
help="end pid") | |
args = parser.parse_args() | |
run(args.start, args.end) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment