2

I'm trying to do something like this to parse a homepage with a login page but Invoke-WebRequest doesn't return anything.

The page I'm trying to access is https://www.suidoapp.waterworks.metro.tokyo.lg.jp/#/login and the code I'm running is this:

$TopURI = "https://www.suidoapp.waterworks.metro.tokyo.lg.jp/#/login"
$TopPage = Invoke-WebRequest -Method Get -Uri $TopURI -SessionVariable MySession -UseBasicParsing

When I look at the Content or RawContent of the $TopPage I can see that it just says "please enable JavaScript" (I've tried both with and without -UseBasicParsing). If I open the page in developer tool in my browser I can see that response for the initial document is the same:

enter image description here

But the interesting thing is that even though the initial page says "please enable JavaScript" the page actually loads:

enter image description here

Has anyone seen this before, where Invoke-WebRequest fails because the response is "please enable JavaScript" yet the page should actually be able to load? Is there another way for me to parse a homepage and send in login forms when Invoke-WebRequest fails like this?

Tanaka Saito
  • 943
  • 1
  • 17
  • 40

1 Answers1

-1

I am having the same issue. The simple answer is: Invoke-WebRequest is not allowed to run javascript for fear of XSS attacks which makes total sense. In my case, I needed to run a Vue.js app via Task Scheduler (on Windows machine in conjunction with IIS). I eventually let PowserShell open a browser and finish the work then close it.

Start-Process -file iexplore -arg 'http://localhost:8080/ (or any URL)' -PassThru
sleep 10
(Get-Process -Name iexplore).Kill()

If you would like to run Firefox instead,

Start-Process -file 'C:\Program Files\Mozilla Firefox\firefox.exe (or your ff location)' -arg 'http://localhost:8080/ (or any URL)' -PassThru
sleep 10
(Get-Process -Name firefox).Kill()

Going back to your question, the loaded page is probably not functional if it invokes any javascript functions. If you talk about form login, you can find resources easily such as this: https://community.auth0.com/t/forms-login-via-curl-or-powershell/17456/3

G Wolfe
  • 1
  • 1