forked from materiaraiding/materiaraiding-old
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfetch_data.ps1
21 lines (16 loc) · 915 Bytes
/
fetch_data.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# Fetches data from XIVAPI and saves it into the Data file directory to be used during the Jekyll Build process
$Response = Invoke-WebRequest -Uri "https://xivapi.com/status?&limit=3000" -Headers $headers -ContentType "application/json" -Method Get -UseBasicParsing
$initcontent = $Response.Content | ConvertFrom-Json
$pages = $initcontent.pagination.PageTotal
$page = 1
$data = @()
write-host "Fetching XIV Status Info - ($pages pages)"
while ($page -le $pages) {
$Response = Invoke-WebRequest -Uri "https://xivapi.com/status?page=$page&limit=3000" -Headers $headers -ContentType "application/json" -Method Get -UseBasicParsing
$content = $Response.Content | ConvertFrom-Json
$data = $data + $content.Results
write-host "https://xivapi.com/status?page=$page"
$page++
}
write-host "Writing JSON data to data file directory"
$data | ConvertTo-Json | Set-Content -Path './_data/status.json'