-
Notifications
You must be signed in to change notification settings - Fork 0
/
rightmove_image_downloader.ps1
42 lines (31 loc) · 1.33 KB
/
rightmove_image_downloader.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
CLEAR
$url=Read-Host -Prompt 'Input a Right Move URL and press enter'
function GetStringBetweenTwoStrings($openingtag, $closingtag, $html)
{
$pattern = "$openingtag(.*?)$closingtag"
$result = [regex]::Match($html,$pattern).Groups[1].Value
return $result
}
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls -bor [Net.SecurityProtocolType]::Tls11 -bor [Net.SecurityProtocolType]::Tls12
$webreq = Start-BitsTransfer $url
$html=$webreq.Content #| Out-File C:\temp\output.txt
$title=GetStringBetweenTwoStrings -openingtag "<title>" -closingtag "</title>" -html $html
$foldername="$((Get-Date).ToString('yyyyMMdd'))_$($title -replace " ","_")"
Write-Host $foldername
$saveto=".\RIGHTMOVE\$($foldername)"
[System.IO.Directory]::Exists($saveto)
if (!(Test-Path $saveto)) {
Write-Warning "$saveto does not exist, it will be created now"
New-Item -Path $saveto -ItemType Directory
}
Write-Host "Title: $title"
Write-Host "URL: $url"
$metatags = ([regex]'<meta property="og:image" ((.|\n|\r)+?)\/>').Matches($html)
[int]$int=1
ForEach ($metatag in $metatags)
{
$imageurl=(($metatag -replace "`"/>","") -replace "<meta property=`"og:image`" content=`"","")
Write-Host $imageurl
Start-BitsTransfer $imageurl -Destination "$($saveto)`\Image_$('{0:d2}' -f [int]$int).jpg" -MaxDownloadTime 1500
$int++
}