2016-06-24 5 views
1

웹 페이지로 이동하는 데 PowerShell을 사용하고 있습니다.PowerShell - 웹 페이지에서 div를 반복하고 ID를 인쇄하십시오.

$ie = New-Object -com InternetExplorer.Application 

$ie.visible=$true 

$ie.navigate("URL") 

$divs = $ie.document.getElementsByTagName("div") 
Foreach($div in $divs) 
{ 
    $div 
} 

이렇게하면 div가 "System .__ ComObjects"로 식별됩니다. 를 Get-Member는 약속 소리 "ie9_getAttribute"(나는 IE11을 사용하고 있지만 ...)하지만 "$ div.ie9_getAttribute ("ID ")"와 같은 방법을 반환하는 것은 던졌습니다 :

Exception calling "ie9_getAttribute" with "1" argument(s): "Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))" 

최초의 div 및 :

Method invocation failed because [System.__ComObject] doesn't contain a method named 'ie9_getAttribute'. 

다음 divs.

Here is the HTML I am parsing.

가 어떻게이 "시스템 .__하여 ComObject '에서 ID를 추출 할 수 ? 당신이 $divs의 개체를 반복하고 같은

답변

0

당신은 단순히 각 개체의 .id 속성을 얻을 필요가 :

Foreach($div in $divs) 
{ 
    $div.id 
} 
관련 문제