Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Site to grab
- $URL = 'http://www.bww-law.com/sales.asp'
- # Grab content
- $Result = Invoke-WebRequest $URL
- # Collection to hold the bits
- [System.Collections.ArrayList]$Properties = @{}
- # Loop through array to [hopefully] grab the
- for($i=0; $i -lt $Result.AllElements.Count; $i++)
- {
- write-host "i [$i]"
- if(!$Result.AllElements[$i].Class) { continue }
- if([string]::IsNullOrEmpty($Result.AllElements[$i])) { continue }
- if([string]::IsNullOrEmpty($Result.AllElements[$i].innerText)) { continue }
- if([string]::IsNullOrEmpty($($Result.AllElements[$i] | select -ExpandProperty innerText))) { continue }
- if([string]::IsNullOrEmpty($($Result.AllElements[$i] | select -ExpandProperty innerText))) { continue }
- if($($Result.AllElements[$i] | select -ExpandProperty innerHTML).Trim() -like ' *') { continue }
- if($($Result.AllElements[$i] | select -ExpandProperty innerHTML).Trim() -like '<!--*') { continue }
- if($($Result.AllElements[$i] | select -ExpandProperty innerHTML).Trim() -like '<A href="#*') { continue }
- if($($Result.AllElements[$i] | select -ExpandProperty innerText).Trim() -eq 'Virginia Sales') { continue }
- if($($Result.AllElements[$i] | select -ExpandProperty innerText).Trim() -like '*All sales in Virginia are conducted*') { continue }
- if(($Result.AllElements[$i] | select -ExpandProperty innerText) -like 'Jurisdiction') { continue }
- if(($Result.AllElements[$i] | select -ExpandProperty innerText) -like 'File #') { continue }
- if(($Result.AllElements[$i] | select -ExpandProperty innerText) -like 'Sale Date') { continue }
- if(($Result.AllElements[$i] | select -ExpandProperty innerText) -like 'Sale Time') { continue }
- if(($Result.AllElements[$i] | select -ExpandProperty innerText) -like 'Property Address') { continue }
- if(($Result.AllElements[$i] | select -ExpandProperty innerText) -like 'City') { continue }
- if(($Result.AllElements[$i] | select -ExpandProperty innerText) -like 'Zip') { continue }
- if(($Result.AllElements[$i] | select -ExpandProperty innerText) -like '*Loan Amount*') { continue }
- $Class = $Result.AllElements[$i].Class
- write-host "Class [$Class]"
- $CityCounty = $Result.AllElements[$i] | select -ExpandProperty innerText
- write-host "CityCounty [$CityCounty]"
- $JurisdictionFileNumber = $Result.AllElements[$i+4] | select -ExpandProperty innerText
- write-host "JurisdictionFileNumber [$JurisdictionFileNumber]"
- $SaleDate = $Result.AllElements[$i+5] | select -ExpandProperty innerText
- write-host "SaleDate [$SaleDate]"
- $SaleTime = $Result.AllElements[$i+6] | select -ExpandProperty innerText
- write-host "SaleTime [$SaleTime]"
- $PropertyAddress = $Result.AllElements[$i+7] | select -ExpandProperty innerText
- write-host "PropertyAddress [$PropertyAddress]"
- $City = $Result.AllElements[$i+8] | select -ExpandProperty innerText
- write-host "City [$City]"
- $Zip = $Result.AllElements[$i+9] | select -ExpandProperty innerText
- write-host "Zip [$Zip]"
- $OriginalLoanAmount = $Result.AllElements[$i+10] | select -ExpandProperty innerText
- write-host "OriginalLoanAmount [$OriginalLoanAmount]"
- $Properties += [pscustomobject]@{CityCounty = $CityCounty;
- JurisdictionFileNumber = $JurisdictionFileNumber;
- SaleDate = $SaleDate;
- SaleTime = $SaleTime;
- PropertyAddress = $PropertyAddress;
- City = $City;
- Zip = $Zip;
- OriginalLoanAmount = $OriginalLoanAmount;
- MapLink = "https://maps.google.com/maps?q=$($PropertyAddress.Replace(' ','+'))+$City+VA+$Zip"
- SearchLink = "https://google.com/search?q=$($PropertyAddress.Replace(' ','+'))+$City+VA+$Zip"
- }
- Remove-Variable Class,CityCounty,JurisdictionFileNumber,SaleDate,SaleTime,PropertyAddress,City,Zip,OriginalLoanAmount -ErrorAction SilentlyContinue
- break
- }
Advertisement
Add Comment
Please, Sign In to add comment