-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathget_items.py
27 lines (24 loc) · 849 Bytes
/
get_items.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
import json
import html
import time
import requests
if __name__ == "__main__":
counter = 0
items = {"names": []}
while True:
try:
url = f"https://poewiki.net/w/api.php?action=cargoquery&tables=items"
url += f"&fields=_pageName=name&format=json&order_by=name&limit=500&offset={counter}"
response = requests.get(url)
response_json = response.json()
if not response_json['cargoquery']:
break
for item in response_json['cargoquery']:
items["names"].append(item["title"]["name"].replace(""", ""))
counter += 500
print("Sleeping, counter is at ", counter)
time.sleep(2)
except Exception:
break
with open("items.json", "w") as file:
json.dump(items, file)