We got a request on FoxDeploy a few days ago asking the following:
I know its been awhile but im looking to write a fun little script that pulls the current food truck and perhaps the next one or two as well from seattlefoodtruck.com. For instance “https://www.seattlefoodtruck.com/schedule/plaza-east” The javascript that runs outputs the details but no matter what i do i cannot access the contents of the output. Any help on what im missing?
First off, we loaded up the URL in Chrome and then opened up devtools and went to the network tab, then refreshed. We're looking for XHR requests
Filtering down to XHR requests (which is what an AJAX request will basically always be) we see just one request. We have a good idea its going to be AJAX, as a nice website like this will most of the time break their components up into reusable modules or Partial Views, and will composite the whole thing together with a few requests.
Clicking into the request, we see a number of the restaurants listed here....looks like we're in the right neighborhood!
We can then copy the request like this...
And paste it into an Invoke-RestMethod
cmdlet and then assign the results to a variable and play with them a bit...