Invoke-webrequest -get request through a custom Chrome profile

1.2k Views Asked by At

I've been looking to ways to read HTML on a opened custom chrome profile, but with no luck.

& "C:\Program Files\Google\Chrome\Application\chrome.exe" --profile-directory="Profile 1" $url;

I tried using invoke-webrequest but couldn't figure out how to get it to work through a custom profile.

The point is to read if an item was bought on $url, where "Profile 1" is logged into.

Alternatively I thought about logging into $url with POST method and then returning the HTML as a variable, but I couldn't figure out a way to do that either.

1

There are 1 best solutions below

0
On BEST ANSWER

This won't work. This can't work.

You can :

  • Launch Chrome on a specific profile
  • Use Invoke-RestMethod and / or Invoke-WebRequest

The two are not correlated though. The Powershell cmdlets do not depend on Chrome for their operations.

If you want to do stuff through Chrome, you need to do browser automation. That's a different thing that require specialized tools, such as Selenium.

You can use the .Net interface of selenium directly or use the Selenium powershell module that will help you interface with selenium (and your browser of choice / browser profile) more easily.

To install :

Install-Module -Name Selenium -AllowPrerelease

Note that this tool is a lot more complex to learn and use than just Invoke-WebRequest

References

Github - Selenium-Powershell

Powershell Gallery - Selenium