初级数据分析之powershell智联招聘网站统计_北上广招聘职位信息

Function Search-Position{
param(
[string]$keyword,
[string]$city)
$url="http://sou.zhaopin.com/jobs/searchresult.ashx?jl=$city&kw=$keyword&p=1&isadv=0"
$page=Invoke-RestMethod $url
 
$AverageSalary = [regex]::Matches($page,'zwyx">(?.*)') |
foreach {
    $salary = $_.Groups['salary'].Value
    if($salary -ne '面议'){
    Write-Debug $salary
    ($salary -split '-' | measure -Average ).Average
    }
} | measure -Average | select -ExpandProperty Average
 
$positonCount = [regex]::Match($page,'共(?.*)个职位满足条件').Groups['positons'].Value
@{
PositonsCount=$positonCount
AverageSalary=$AverageSalary
}
}
 # 还有一个是 invoke-webRequest
'上海','杭州','南京','苏州','南昌','西安' | ForEach-Object{
 
$s= Search-Position -keyword '.net开发' -city $_
[PSCustomObject]@{
城市=$_
职位个数=$s.PositonsCount
平均市场薪资=[int]$s.AverageSalary
}
} | Format-Table

你可能感兴趣的:(Powershell,powershell,数据分析)