forked from b3n-j4m1n/salary-seeker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
salary-seeker.ps1
72 lines (65 loc) · 3.21 KB
/
salary-seeker.ps1
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
61
62
63
64
65
66
67
68
69
70
71
72
### seek salary seeker
### rewritten from https://github.com/b3n-j4m1n/salary-seeker
Param (
[Parameter(Mandatory=$true)]
[int]$job_id
)
### initial variables
$url_base = 'https://jobsearch-api.cloud.seek.com.au/search?'
$strMin, $strMax, $strRep = ""
$counter = 1
$response = 1
$upper_lim = 250000
$lower_lim = 20000
$salary_var = ($lower_lim + (($upper_lim - $lower_lim)/2))
$job_data=(ConvertFrom-Json(Invoke-WebRequest -UseBasicParsing -Uri "$($url_base)jobid=$($job_id)")).data
### Go!
Clear-Host
Write-Host "Job Title:" $job_data.title "| Advertiser:" $job_data.advertiser.description
Write-Host "Type: $($job_data.workType) | Location: $($job_data.location)"
Write-Host $job_data.teaser
Write-Host "Job ID: $($job_data.id)"
### find maximum
while ($counter -lt 19) {
$response=(ConvertFrom-Json(Invoke-WebRequest -UseBasicParsing -Uri "$($url_base)keywords=$($job_data.teaser)&advertiserid=$($job_data.advertiser.id)&sourcesystem=houston&salaryrange=$([math]::round($salary_var,0))-$([math]::round($upper_lim,0))")).data | Where-Object {$_.id -eq $job_id}
if(($response|measure-object).Count -eq 1) {
$lower_lim=$salary_var
$salary_var=($salary_var + (($upper_lim - $salary_var) / 2))
#Write-host "MAX found 1, new upper: $($upper_lim), new lower: $($salary_var)"
}
elseif(($response|measure-object).Count -eq 0) {
$upper_lim=$salary_var
$salary_var=($salary_var - (($salary_var - $lower_lim) / 2))
#write-host "MAX found 0, new upper: $($upper_lim), new lower: $($salary_var)"
}
$counter ++
#Write-Host "MAX - Var: $($salary_var), lower: $($lower_lim), upper: $($upper_lim)"
}
$salary_max = $salary_var
Write-verbose "BETWEEN CALCS - Var: $($salary_var), lower: $($lower_lim), upper: $($upper_lim)"
### variable reset
$counter = 1
$lower_lim = 25000
$upper_lim = $salary_max
$salary_var = ($lower_lim + (($upper_lim - $lower_lim) / 2))
### find minimum
while ($counter -lt 16) {
$response=(ConvertFrom-Json(Invoke-WebRequest -UseBasicParsing -Uri "$($url_base)keywords=$($job_data.teaser)&advertiserid=$($job_data.advertiser.id)&sourcesystem=houston&salaryrange=$([math]::round($lower_lim,0))-$([math]::round($salary_var,0))")).data | Where-Object {$_.id -eq $job_id}
if(($response|measure-object).Count -eq 1) {
$upper_lim=$salary_var
$salary_var=($salary_var - (($salary_var - $lower_lim) / 2))
#write-host "MIN found 1, new upper: $([math]::round($salary_var,2)), new lower: $([math]::round($lower_lim,2))"
}
elseif(($response|measure-object).Count -eq 0) {
$lower_lim=$salary_var
$salary_var=($salary_var + (($upper_lim - $salary_var) / 2))
#write-host "MIN found 0, new upper: $([math]::round($salary_var,2)), new lower: $([math]::round($lower_lim,2))"
}
$counter ++
}
$salary_min = $salary_var
Write-Host "-----------------"
if($salary_min -eq ""){$strMin="Minimum salary: unknown"}else{$strMin="Minimum salary: `$$([math]::round($salary_min,2))"}
if($salary_max -eq ""){$strMax="Maximum salary: unknown"}else{$strMax="Maximum salary: `$$([math]::round($salary_max,2))"}
if($job_data.salary -ne ""){$strRep="| Reported Range: $($job_data.salary)"}
Write-Host "$strMin | $strMax $strRep"