iamnot ahater
iamnot ahater

Reputation: 41

Powershell doesn't work like I want it to

My problem with this powershell script is that I want to get table content from number 3 table:

enter image description here

Number 3 table has a different URL ending than the first two and problem with my script is that, no matter what I do, I can't get information from the third one. I have tried by ID name and all that but nothing seems to work. If I change the URL it will still get info From the first and second, and if I let it run so that maybe it can pull something from third one but it always stops at the end of a second one. For the ending line I only want to communicate with the third table. I want something like this↓

enter image description here

$Uri = "https://etherscan.io/address/0xcd895fc1c9e24c5c5ce3fb692593c402bbfb53c7#tokentxns"

$InfoPage = Invoke-Webrequest -Uri $Uri

$InfoPage.ParsedHtml.getElementsByTagName("tbody") | ForEach-Object {

    $Headers = $null

    $_.getElementsByTagName("tr") | ForEach-Object {
        $OutputRow = $_.getElementsByTagName("td") | Select-Object -ExpandProperty InnerText
        $OutputRow[6].Trim()
        $OutputRow[4].Trim()
    }
}

Upvotes: 0

Views: 134

Answers (1)

Frenchy
Frenchy

Reputation: 17027

i have looked at the html page and you have an iframe for this table and the id of this iframe is tokenpageiframe

$Uri = "https://etherscan.io/address/0xcd895fc1c9e24c5c5ce3fb692593c402bbfb53c7#tokentxns"
$InfoPage = Invoke-Webrequest -Uri $Uri

$iframe = $InfoPage.ParsedHtml.getElementById('tokenpageiframe');

$iframe.document.getElementsByTagName("tbody") | ForEach-Object {

    $Headers = $null

    $_.getElementsByTagName("tr") | ForEach-Object {
        $OutputRow = $_.getElementsByTagName("td") | Select-Object -ExpandProperty InnerText
        $OutputRow[6].Trim()
        $OutputRow[4].Trim()
    }
}

Upvotes: 1

Related Questions