Created
April 12, 2018 09:02
-
-
Save kazuple/eb96a856c79f0fc238be310824cf3559 to your computer and use it in GitHub Desktop.
Powershell - If web page has been updated? Push notification to webhook URL!
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
<############################################################## | |
If webpage has been updated? Push notification to webhook URL! | |
Created: 17/01/18 | |
By: Karl Smith | |
Version: 0.1 | |
###############################################################> | |
# URL to scrape | |
$url ='URL to scrape' | |
# Test URL | |
#$url ='' | |
# Request Webpage | |
$response = Invoke-WebRequest -Uri $url | |
# Webhook URL | |
$webhook = 'Webhook URL' | |
# Webook Parameters | |
$params = @{ | |
Headers = @{'accept'='application/json'} | |
Body = $bodytext | convertto-json | |
Method = 'Post' | |
URI = $webhook | |
} | |
# Todays Date | |
$todaysdate = get-date -format M/dd/yyyy | |
# LastUpdated div id | |
$LastUpdated = $response.AllElements.FindById('LastUpdated') | select innerText | |
# If LastUpdated div content is equal to todays date, send http post to webhook url. | |
if($LastUpdated.innerText -eq $todaysdate){ | |
$bodytext = @{ | |
'text'= "Text to include in the HTTP POST" | |
} | |
Invoke-RestMethod @params | |
}else{ | |
write-host ("No update today :(") | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment