Skip to content

Instantly share code, notes, and snippets.

@kazuple
Created April 12, 2018 09:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kazuple/eb96a856c79f0fc238be310824cf3559 to your computer and use it in GitHub Desktop.
Save kazuple/eb96a856c79f0fc238be310824cf3559 to your computer and use it in GitHub Desktop.
Powershell - If web page has been updated? Push notification to webhook URL!
<##############################################################
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