System.__ComObject String Representation


i have noob question. have variable of type system.__comobject, , want try string representation of debugging purposes. when print variable, "system.__comobject" displayed.

for context, have basic html page looks this:
<html>
    <body>
        <table>
            <tr>
                <th>...</th>
            </tr>
            <tr>
                <td><a href...>...</a></td>
            </tr>
            ...
        </table>
    </body>
</html>

and trying drill down href links in table. have code:

$webclient = new-object system.net.webclient
$webclient.usedefaultcredentials=$true
$geturl = invoke-webrequest $url
$webpage = $geturl.parsedhtml.body
$list = $webpage.table#.tr
echo "list: $webpage"
if($list -eq $null) {
    echo "list null"
} else {
    echo "list not null"
}

where $list null reason. attempting determine $webpage contains can figure out why can't find table tag.

any appreciated.

hi aussiemcgr,

we can view available methods via "$webpage|get-member" before use method.

if there tables inside webpage, please try use script below:

 @($geturl.parsedhtml.getelementsbytagname("table"))[0].outerhtml

for more detailed information script, please check article:

importing website tables excel

if there else regarding issue, please feel free post back.

best regards,

anna wang



Windows Server  >  Windows PowerShell



Comments

Popular posts from this blog

Error: 0x80073701 when trying to add Print Services Role in Windows 2012 Standard

Disconnecting from a Windows Server 2012 R2 file sharing session on a Windows 7,8,10 machine

Event ID 64,77,1008 Certificates Events Windows Server 2008, 2008R2