简单的网页监控脚本
之乎者也 Lv3

简单的网页监控脚本,网页不能访问时声音提醒

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
#要监控的网页
$url = "https://www.baidu.com/404"
#发生错误打开的网页
$url2 = "https://www.bilibili.com/video/BV1jg411C7Nj/?spm_id_from=333.1007.top_right_bar_window_default_collection.content.click&vd_source=ed9eb039dcc49a6881ce976b77c9c511"
$bb = $True
$a = 1
while($bb)
{
Write-Host $a
try {


$response = Invoke-WebRequest -Uri $url

if ( $response.StatusCode -gt 300){
Write-Host "StatusCode error"
Start-Process $url2
$bb = $False
}
}
catch {
Write-Host "error"
Start-Process $url2
$bb = $False
}

Start-Sleep -m 5000
$a ++
}