forked from AricStewart/ffxiv_craft
-
Notifications
You must be signed in to change notification settings - Fork 0
/
refresh_inventory.py
executable file
·60 lines (52 loc) · 1.81 KB
/
refresh_inventory.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#!/usr/bin/python
import os
import re
import time
import dotenv
import requests
dotenv.load_dotenv()
SQEXID = os.getenv("SQEXID")
PASSWORD = os.getenv("PASSWORD")
CHARACTER_ID = os.getenv("CHARACTER_ID")
RETAINER_COUNT = os.getenv("RETAINER_COUNT")
RETAINER_ID = list()
for x in range(1, int(RETAINER_COUNT) + 1):
RETAINER_ID.append(os.getenv("RETAINER_ID_" + str(x)))
session = requests.session()
login = session.get('https://na.finalfantasyxiv.com/lodestone/account/login/')
print login
val = re.findall('(oauthlogin.send.*)"', login.text)
val = val[0].split('"', 2)
url = 'https://secure.square-enix.com/oauth/oa/'+val[0]
stored = re.findall('_STORED_" value=(.*)"', login.text)[0]
stored = stored.strip('"');
payload = {'sqexid':SQEXID,
'password':PASSWORD,
'_STORED_' : stored,
'wfp':1}
core = session.post(url, payload)
print core
part2 = re.findall('action="(.*)"', core.text)[0]
part2 = part2.replace("&", "&")
hidden = re.findall('value="(.*)"', core.text)[0]
payload = {'cis_sessid': hidden, 'provision' : "", '_c' : "1"}
core2 = session.post(part2, payload)
print core2
csrf = re.findall('csrf_token" value=(.*)"', core2.text)[0]
csrf = csrf.strip('"');
url = 'https://na.finalfantasyxiv.com/lodestone/api/account/select_character/'
stamp = int(time.time() * 1000)
payload = {'csrf_token': csrf,
'character_id': CHARACTER_ID,
'__timestamp': stamp}
core3 = session.post(url, payload)
print core3
for entry in RETAINER_ID:
index = str(RETAINER_ID.index(entry) + 1)
core4 = session.get('https://na.finalfantasyxiv.com/lodestone/character/' +
CHARACTER_ID + '/retainer/' + entry + '/baggage/')
print index, core4
f = open('./inventory/inv'+ index + '.html', 'wb')
b = bytearray(core4.text, 'utf8')
f.write(b)
f.close()