NoahGrg
NoahGrg

Reputation: 1

Scraping data from site using _dopostback method - Powershell

I have a web-page that shows a table with 10 entries only. There are page numbers below the table 1,2,3,4...... Clicking on each will call a _dopostback method which takes in event argument and event target as parameters and displays the next 10 entries in the table. The page is an aspx page. I want to be able to extract the data in the table from all the pages.. New to powershell need help :(

$login = Get-Credential -Message "Enter Creds: "

$url = "hxxp:www.xxxxxxxx.com/index.aspx"

Invoke-WebRequest $url `
    -SessionVariable $session `
    -UseBasicParsing

$addUserSite = Invoke-WebRequest $url -WebSession 

$addUserForn = $addUserSite.Forms[0]

$addUserForm.Fields["_EVENTTARGET"]="GridView3"

$addUserForm.Fields["_EVENTARGUMENT"]="Page$1"

$Response = Invoke-WebRequest `
    -Credential $login `
    -uri $url `
    -method post `
    -Body $addUserForm.Fields `
    -WebSession $session `
    -UseBasicParsing $Response.AllElements `
    | Where {$_.TagName -eq "td"} `
    | select outerText

Upvotes: 0

Views: 70

Answers (0)

Related Questions