Home > other >  Invoke-WebRequest not returning results as expected
Invoke-WebRequest not returning results as expected

Time:02-24

I am running this code and its not returning the data to my $response variable as I expected.

$targetUrl = "https://www.tigerrunresort.com/vacation-rentals-homes-search.asp?txtStartDate=8/1/2022&txtEndDate=8/7/2022&categoryid=11317&destinationID=0&communityID=0&amenBedrooms=-1&maxPersons=0&advs=&sort=0&currentPage=1&flexibleDates=0&flexibleDatesThreshold=&searchAmenities=&showOnlySpecials=0"
 
$Response = Invoke-WebRequest -Uri $targetUrl

In rawcontent I should expect to see the string "Sorry" which does not show. What do I need to do to get it to return the values as I would see interactively?

Thanks!

CodePudding user response:

You are not seeing it because it is not actually in the response. It is probably created and appended to the DOM by Javascript. Due to the Invoke-WebRequest not executing Javascript, it is never part of the response. If you are looking to orchestrate browsers (which do execute Javascript and offer access to the DOM) maybe you can try taking a look at Selenium (https://www.selenium.dev/)

CodePudding user response:

For lauching a web request you can use for example start-process like this : start-process microsoft-edge:http://google.com/

  • Related