Last active
August 28, 2023 18:02
-
-
Save neonichu/5186336 to your computer and use it in GitHub Desktop.
Demo of accessing the Ingress API.
This file contains hidden or 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 | |
import cookielib | |
import json | |
import mechanize | |
##### | |
GOOGLE_USER = '[email protected]' | |
GOOGLE_PASS = 'your-password' | |
##### | |
cookiejar = cookielib.LWPCookieJar() | |
browser = mechanize.Browser() | |
browser.set_cookiejar(cookiejar) | |
browser.open('http://ingress.com/intel') | |
for link in browser.links(url_regex='ServiceLogin'): | |
browser.follow_link(link) | |
browser.select_form(nr=0) | |
browser.form['Email'] = GOOGLE_USER | |
browser.form['Passwd'] = GOOGLE_PASS | |
browser.submit() | |
req = mechanize.Request('http://www.ingress.com/rpc/dashboard.getGameScore', | |
'{"method": "dashboard.getGameScore"}') | |
# req = mechanize.Request('http://www.ingress.com/rpc/dashboard.getThinnedEntitiesV2', '{\ | |
# "minLevelOfDetail": -1,\ | |
# "boundsParamsList": [\ | |
# {\ | |
# "id": "01202031112",\ | |
# "minLatE6": 52052490,\ | |
# "minLngE6": 10546875,\ | |
# "maxLatE6": 52268157,\ | |
# "maxLngE6": 10898438,\ | |
# "qk": "01202031112"\ | |
# },\ | |
# {\ | |
# "id": "01202031102",\ | |
# "minLatE6": 52052490,\ | |
# "minLngE6": 9843750,\ | |
# "maxLatE6": 52268157,\ | |
# "maxLngE6": 10195313,\ | |
# "qk": "01202031102"\ | |
# }\ | |
# ],\ | |
# "method": "dashboard.getThinnedEntitiesV2"\ | |
# }') | |
# req = mechanize.Request('http://www.ingress.com/rpc/dashboard.getPaginatedPlextsV2', '{\ | |
# "desiredNumItems": 50,\ | |
# "minLatE6": 52146678,\ | |
# "minLngE6": 10138557,\ | |
# "maxLatE6": 52397517,\ | |
# "maxLngE6": 10917213,\ | |
# "minTimestampMs": -1,\ | |
# "maxTimestampMs": -1,\ | |
# "method": "dashboard.getPaginatedPlextsV2"\ | |
# }') | |
for cookie in cookiejar: | |
if cookie.name == 'csrftoken': | |
req.add_header('X-CSRFToken', cookie.value) | |
cookiejar.add_cookie_header(req) | |
jsonData = '\n'.join(mechanize.urlopen(req).readlines()) | |
print json.loads(jsonData) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi.
Could you please answer about what to do if now this ingress requests are not working? I need to another links to api or it does not work because of they have closed it?