Last active
December 17, 2015 10:09
-
-
Save nikop/5592734 to your computer and use it in GitHub Desktop.
CDON Varastosaldo
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 urllib, urllib.request | |
import http, http.cookiejar | |
import re | |
import argparse | |
parser = argparse.ArgumentParser() | |
parser.add_argument("id") | |
args = parser.parse_args() | |
m3 = re.search('(\d+)$', args.id) | |
o = urllib.request.build_opener(urllib.request.HTTPCookieProcessor(http.cookiejar.CookieJar())) | |
data = { | |
'productId': m3.group(1), | |
'quantity': 10000, | |
'type': 'json', | |
'ticket': 'null', | |
} | |
post = urllib.parse.urlencode(data).encode('utf-8') | |
r = o.open('http://cdon.fi/CartUpdate/Add/', post) | |
t = r.read().decode('utf-8') | |
c = o.open('http://cdon.fi/order/checkout') | |
t2 = str(c.read().decode('utf-8')) | |
m = re.search('input type="hidden" name="product-quantity-(\d+)" value="(\d+)"', t2) | |
m2 = re.search('(\d+)">([^<]+)</a>', t2) | |
print(m2.group(2), m.group(2)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment