The follow code is to log into a website, save the session, then run a request against a page inside the site. However, everything I do keeps returning the original page.
$username = "user"; $password = "pw"
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
$url = "https://testsite.com/loginpage.jsp"
$url2 = "https://testsite.com/id=1764017344"
$r = Invoke-WebRequest -Uri $url -SessionVariable Session
$form = $r.Forms[0]
$form.fields['login'] = $username
$form.fields['password'] = $password#the names of the login/password controls are login/password
$r = Invoke-WebRequest -Uri ($url + $form.Action) -WebSession $Session -Method POST -Body $form.Fields
$r2 = Invoke-WebRequest -Uri $url2 -WebSession $Session -Method Get
$r2.AllElements
The allelements is returning values for the login page, not the ID page.....
Aucun commentaire:
Enregistrer un commentaire