Update data with cron to prevent api rate limiting
This commit is contained in:
parent
c1deb8a20c
commit
e3ae8e1b81
8 changed files with 1006 additions and 122 deletions
25
update/update_clan.ps1
Normal file
25
update/update_clan.ps1
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
|
||||
# Read the content of the file as a single string
|
||||
$fileContent = Get-Content -Path "../config/config.php" -Raw
|
||||
|
||||
# Use regex to match the apiKey value
|
||||
if ($fileContent -match "\`$apiKey\s*=\s*\'([^\']+)\'") {
|
||||
$apiKey = $matches[1]
|
||||
}else {
|
||||
Write-Output "API Key not found"
|
||||
}
|
||||
|
||||
if ($fileContent -match "\`$clanid\s*=\s*\'([^\']+)\'") {
|
||||
$clanid = $matches[1]
|
||||
} else {
|
||||
Write-Output "No clanid found in $configPath"
|
||||
}
|
||||
|
||||
|
||||
|
||||
$headers = @{
|
||||
'accept' = 'application/vnd.api+json'
|
||||
'Authorization' = "$apiKey"
|
||||
}
|
||||
$claninfo = Invoke-RestMethod -Uri "https://api.pubg.com/shards/steam/clans/$clanid" -Method GET -Headers $headers
|
||||
$claninfo.data.attributes | convertto-json -Depth 100 | out-file '../data/claninfo.json'
|
||||
Loading…
Add table
Add a link
Reference in a new issue