Любой язык - [решено] Скачиваине странички целиком

Аватара пользователя
jack_nuclear

Re: Любой язык - [решено] Скачиваине странички целиком

Сообщение jack_nuclear »

jack_nuclear, личка у меня «забита» доверху, пишите на почту или непосредственно сюда.
Аватара пользователя
jack_nuclear

Re: Любой язык - [решено] Скачиваине странички целиком

Сообщение jack_nuclear »

Iska, Доброго времени суток. Под powershell 7 не работает. Пишет

Код:

Код: Выделить всё

Cannot find an overload for "getElementsByClassName" and the argument count: "1"

У PS7

Document : System.__ComObject



У PS5

Document : mshtml.HTMLDocumentClass



$oIE | Get-Member - говорит есть свойство Document

$oIE.Document | Get-Member - говорит есть метод getElementsByClassName



Подозреваю проблема в Microsoft.mshtml.dll. Подскажите что делать. Так не хочу запускать PS5 из PS7





p.s. в дебрях гугла нашел вот такое





Код:

Код: Выделить всё

$oIE=new-object -com internetexplorer.application
$oIE.navigate2(“about:blank”)
while ($oIE.busy) {
    sleep -milliseconds 50
}
$oIE.visible=$true
$procList=ps |select-object ProcessName,Handles,NPM,PM,WS,VM,CPU,Id |convertto-html
$oDocBody=$oIE.document.documentelement.lastchild ;
#populate the document.body
$oDocBody.innerhtml=$procList
$oDocBody.style.font=”12pt Arial”;
$oIE.document.bgcolor=”#D7D7EA”
#Reading back from IE.
$oTBody=@($oIE.document.getElementsByTagName(“TBODY”))[0] ;
foreach ($oRow in $oTBody.childNodes)
{
   #check the 4 column(WS),and highlight it if it is greater than 5MB.
   $WS=(@($oRow.childNodes)[4].innerhtml) -as [int]  ;
   if (($ws -ne $null) -and ($WS -ge 5mb)) {
       $oRow.bgColor=”#AAAAAA” ;
   }
}
#Prepare a title.
$oTitle=$oIE.document.createElement(“P”)
$oTitle.style.font=”bold 20pt Arial”
$oTitle.innerhtml=”Process List”;
$oTitle.align=”center” ;
#Display the title before the Table object.
$oTable=@($oIE.document.getElementsByTagName(“TABLE”))[0] ;
$oDocBody.insertBefore($oTitle,$oTable) > $null;

И описание





HTML код:

Код: Выделить всё

Displaying the “$procList”  can also be accomplished with “write” methods instead of innerhtml assignment.  But we should perform some extra checks to determine  whether the document.body  is type of [mshtml.htmldocumentclass]. If the “htmlfile” progid has the following settings in the registry:
HKEY_CLASSES_ROOT\CLSID\{25336920-03F9-11CF-8FD0-00AA00686F13}\InProcServer32 
Class        : mshtml.HTMLDocumentClass
Assembly  : Microsoft.mshtml, Version=7.0.3300.0,  Culture=neutral,       PublicKeyToken=b03f5f7f11d50a3a
then, mshtml.htmldocumentclass become .NET wrapper for the document.body object.
So the following line :
$oDocBody.innerhtml=$procList
Can be replaced with:
If ($oIE.document.psbase.tostring() –eq “system.__comobject”) {
    $oIE.document.write([string]$proclist)
}
else {
    $oIE.document.IHTMLDOcument2_write([string]$proclist)
}
$oDocBody=$oIE.document.documentelement.lastchild ;



но применить это мозгов не хватает. Прошу помощи)
Аватара пользователя
Foreigner

Re: Любой язык - [решено] Скачиваине странички целиком

Сообщение Foreigner »

jack_nuclear, А зачем под PowerShell что-то там мудрить? Закачивайте страницу целиком и работайте с полученным...



Invoke-WebRequest и New-Object System.Net.Webclient в помощь.
Аватара пользователя
Foreigner

Re: Любой язык - [решено] Скачиваине странички целиком

Сообщение Foreigner »

Foreigner, оба не подошли к сайту. Проверка браузера на нем. Подмена User-Agent не спасла
Ответить

Вернуться в «Скриптовые языки администрирования Windows»