Created
May 1, 2021 22:10
-
-
Save goyuix/fc8dd5fe7a77c858a10885f82cb3252e to your computer and use it in GitHub Desktop.
This file contains hidden or 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
$jhrl = 'https://www.jhrl.com' | |
$allPropertiesURL = 'https://www.jhrl.com/sites/default/files/btolazyjump/61db5d1311039d5f62b303d5dd7bbc1d.txt' | |
$wc = New-Object System.Net.WebClient | |
# Download main page, and parse out actuall properties URL | |
$baseHTML = $wc.DownloadString($jhrl) | |
$allPropertiesURL = [Regex]::Matches($baseHTML,'data-bto-jump-select="(.*?). />').Groups[1].Value | |
# Using downloaded properties info, parse out URL for each property | |
$rentals = @{} | |
$rentalTXT = $wc.DownloadString($allPropertiesURL) | |
$rentalOptions = ([xml]($rentalTXT+"</div>")).div.div.select.option | Select-Object -Skip 1 | ForEach-Object { $_.Value.Substring(34) } | |
# Loop over each property, downloading the page and parsing out the Drupal object for availability etc and cache it in the $rentals object | |
$i = 0 | |
foreach ($rental in $rentalOptions) { | |
try { | |
$html = $wc.DownloadString("$jhrl$rental") | |
$json = [Regex]::Matches($html,'<script>jQuery.extend\(Drupal.settings, (.*?)\);</script>').Groups[1].Value | |
$obj = ConvertFrom-Json $json | |
$rentals[$rental] = $obj | |
} catch [WebException] { | |
Write-Error "Error downloading: $rental" | |
} finally { | |
Write-Progress -Activity "Downloading Properties . . ." -Status "Downloaded $i of $($rentalOptions.Count)" -percentComplete (($i / $rentalOptions.Count) * 100) | |
$i++ | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment