Created
April 15, 2015 03:44
-
-
Save dbanetto/6f2d2ec568610c379ebe to your computer and use it in GitHub Desktop.
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 python3 | |
# | |
# Requires Python 3, and requests | |
# | |
# Tested on Linux, python 3.4, requests 2.6.0 | |
# | |
import requests | |
import json, time, datetime, re | |
def main(): | |
headers = { | |
"X-Requested-With": "XMLHttpRequest", # needs this | |
} | |
print("Getting PHPSESSID") | |
headers["Cookie"] = "PHPSESSID={}".format(get_sessid()) | |
print("Got PHPSESSID") | |
print("Getting egg id") | |
egg_id = get_egg_id() | |
print("Got egg id", egg_id) | |
count = 0 | |
while True: | |
try: | |
r = requests.get("http://digimon-adventure.net/application/nade2.php?click={}".format(egg_id), | |
headers=headers) | |
res = json.loads(r.content.decode()) | |
if res['count_start'] != "null": | |
count += 1 | |
print("Patted", count, "times. Pats left:", int(res['count_start']) - int(res['count_current'])) | |
time.sleep(1) | |
else: | |
print("Something did not go right") | |
if count % 100 == 0: | |
print("Refreashing PHPSESSID") | |
headers["Cookie"] = "PHPSESSID={}".format(get_sessid()) | |
except Exception as e: | |
print("Error", type(e) , e) | |
break | |
def get_sessid(): | |
r = requests.get("http://digimon-adventure.net/application/nade2.php") | |
return r.cookies.get('PHPSESSID') | |
def get_egg_id(): | |
r = requests.get("http://digimon-adventure.net/") | |
js_regex = r'<script type="text/javascript" src="(http://210.233.17.71/js/index_\d+.js)"></script>' | |
js_link = re.search(js_regex, r.content.decode()).group(1) | |
r = requests.get(js_link) | |
return re.search(r'var egg_id = (\d+);', r.content.decode()).group(1) | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment