-
-
Save shizhao/4528587 to your computer and use it in GitHub Desktop.
去 http://www.ingress.com/intel 登陆,找到www.ingreww.com的cookie ACSID值和csrftoken值填入变量中。另外去https://code.google.com/apis/console/ 申请一个google+ 的API key填入变量中。
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
#!/usr/bin/env python | |
# -*- encoding: utf-8 -*- | |
# vim: set et sw=4 ts=4 sts=4 ff=unix fenc=utf8: | |
# Author: Binux<1@binux.me> | |
# http://binux.me | |
# shizhao | |
# http://shizhao.org | |
# Created on 2013-01-14 10:29:51 | |
# | |
# From Google+ find passcode | |
import re | |
import cPickle | |
import requests,urllib | |
#G+ API key | |
key = '' | |
#www.ingress.com cookie ACSID | |
acsid = 'ACSID='+'' | |
#www.ingress.com cookie csrftoken | |
csrftoken='csrftoken='+'' | |
gplus = 'https://www.googleapis.com/plus/v1/activities?query=passcode&maxResults=20&fields=items(annotation%2Cobject(attachments%2Fcontent%2Ccontent%2CoriginalContent)%2Ctitle)%2Ctitle&key='+ key | |
cookie = acsid+';'+csrftoken | |
csrf = re.findall('csrftoken=(\w+)', cookie)[0] | |
page=urllib.urlopen(gplus) | |
data=page.read() | |
#find passcode | |
rp = re.findall('\d[A-Za-z]{2}\d[A-Za-z]+\d[A-Za-z]\d[A-Za-z]', data) | |
try: | |
checked = cPickle.load(open('checked.passcode')) | |
except: | |
checked = [] | |
if len(rp) != 0: | |
for p in rp: | |
if p not in checked: | |
r = requests.post('http://www.ingress.com/rpc/dashboard.redeemReward', | |
data = '{"passcode": "%s", "method":"dashboard.redeemReward"}' % p, | |
headers = { | |
'Cookie': cookie, | |
'X-Requested-With': 'XMLHttpRequest', | |
'X-CSRFToken': csrf, | |
}) | |
checked.append(p) | |
try: | |
print p, r.text | |
except: | |
print 'have checked' | |
try: | |
cPickle.dump(checked, open('checked.passcode', 'w')) | |
except: | |
pass |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment