0

I am remodeling my house and need to compare material prices from different websites in order to get the best deal. I am trying to use PowerShell 7.2 and the Invoke-WebRequest command to scrape the item cost. For the life of me, I can't get the following to work and need some help.

$Url = 'https://www.lowes.com/pd/CertainTeed-Common-5-8-in-x-4-1-2-ft-x-12-ft-Actual-0-625-in-x-4-ft-x-12-ft-Drywall-Panel/1003189188'

$WebResponse = Invoke-WebRequest -Uri $Url -UserAgent 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:85.0) Gecko/20100101 Firefox/85.0'

When I execute this in PowerShell 7.2, I get the following error...

Invoke-WebRequest:
Access Denied
Access Denied

You don't have permission to access "http://www.lowes.com/pd/CertainTeed-Common-5-8-in-x-4-1-2-ft-x-12-ft-Actual-0-625-in-x-4-ft-x-12-ft-Drywall-Panel/1003189188" on this server.
Reference #18.25784017.1639352283.bd0c2fa

What am I doing wrong?

1 Answers1

0

I'm experiencing a similar issue. Any IWR I run gets the following response: -

Invoke-WebRequest: The requested address is not valid in its context.

Running powershell 7.2.7 N.B when running the exact same request in powershell 5.1, it works

Charles
  • 1
  • 2
  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Nov 09 '22 at 22:11