Getting an Excuse

by Feb 17, 2016

Here is a quick way of getting a good excuse – provided you have Internet access:

#requires -Version 3
function Get-Excuse
  $url = ''
  $ProgressPreference = 'SilentlyContinue'
  $page = Invoke-WebRequest -Uri $url -UseBasicParsing
  $pattern = '(?m)<br><font size = "\+2">(.+)'
  if ($page.Content -match $pattern)

It illustrates how you can use Invoke-WebRequest to download the HTML content of a webpage, then use regular expressions to scrape content from that page.

Twitter This Tip! ReTweet this Tip!