Created
June 28, 2022 16:03
-
-
Save tackme31/c679bc489dc45806328febbd0b58c52d to your computer and use it in GitHub Desktop.
ホームズの物件で募集中の部屋を出力するやつ
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$chintaiList = @( | |
'https://www.homes.co.jp/archive/b-38203506/', # キングダム相模原 | |
'https://www.homes.co.jp/archive/b-38203509/', # ビバーチェ | |
'https://www.homes.co.jp/archive/b-38201560/' # タウンハウス内堀 | |
) | |
function Write-Recuruitments($archiveUrl) { | |
$result = Invoke-WebRequest $archiveUrl | |
$heading = $result.ParsedHtml.getElementsByClassName('heading') | |
$title = $heading[0].innerText -replace 'の賃貸・中古情報','' -replace 'の賃貸情報','' | |
Write-Output $title | |
$recruitments = $result.ParsedHtml.getElementsByClassName('is-inquire') | |
$recruitments | ForEach-Object { | |
$floorElem = $_.querySelector('.floarCell') | |
$floorElem.innerText -match '(\d+階)' > $null | |
$floor = $Matches[0] | |
$urlElem = $_.querySelector('.roomImage a') | |
$url = $urlElem.href | |
Write-Output "$floor : $url" | |
} | |
} | |
$chintaiList | ForEach-Object { | |
Write-Recuruitments $_ | |
Write-Output '' | |
Write-Output '-----' | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment