<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title><![CDATA[Серый форум &mdash; Jscript:Доступ к логин странице]]></title>
		<link>https://forum.script-coding.com/viewtopic.php?id=6356</link>
		<atom:link href="https://forum.script-coding.com/extern.php?action=feed&amp;tid=6356&amp;type=rss" rel="self" type="application/rss+xml" />
		<description><![CDATA[Недавние сообщения в теме «Jscript:Доступ к логин странице».]]></description>
		<lastBuildDate>Thu, 19 Apr 2012 05:35:23 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Re: Jscript:Доступ к логин странице]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=59548#p59548</link>
			<description><![CDATA[<div class="quotebox"><cite>Евген пишет:</cite><blockquote><p>Тоже хочу открыть свою Америку и стать немного Колумбом в данной теме...<br />Позвольте проверить, правильно ли я понял затею...<br />т.е. прошла авторизация и имеем сессию на сервере с открытой страницей, затем не теряя сессию, в эту же страницу внедряем её же HTML содержимое + свой скрипт, который всё выгружает ? - я правильно понял ?</p></blockquote></div><p>Все правильно <br />При иницилизации объекта XMLHTTP в InternetExplorer.Application он наследует свойста (область видимости).<br />Применительно к интернет-клиенту XMLHTTP использует настройки безопасности сохраненные в IE. <br />Интернет Клиент сбербанка сделан на базе популярного нынче интернет-бакинга Faktura.ru разработанный ЦФТ. </p><p>Xameleon&nbsp; можно ли получить&nbsp; ссылочку на Америку (где есть похожий код с внедрением )?<br /></p><div class="codebox"><pre><code>var head = iE.Document.getElementsByTagName(&quot;head&quot;);
var script = iE.Document.createElement(&quot;script&quot;);
head[0].appendChild(script);
script.type = &quot;text/javascript&quot;;
script.text = &quot;  var myHTTP = new ActiveXObject(\&quot;Microsoft.XMLHTTP\&quot;);&quot;
... 
var HttpReq = iE.Document.parentWindow.myHTTP</code></pre></div><p>Насчет Колумба - XMLHTTP&nbsp; использую <a href="http://bankir.ru/dom/threads/75256-СПО-СВК?p=2347712&amp;viewfull=1#post2347712">в своем скрипте для СПО СВК</a> уже давно. Никогда не использовал УТА.</p>]]></description>
			<author><![CDATA[null@example.com (badik)]]></author>
			<pubDate>Thu, 19 Apr 2012 05:35:23 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=59548#p59548</guid>
		</item>
		<item>
			<title><![CDATA[Re: Jscript:Доступ к логин странице]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=59520#p59520</link>
			<description><![CDATA[<p>Тоже хочу открыть свою Америку и стать немного Колумбом в данной теме...<br />Позвольте проверить, правильно ли я понял затею...<br />т.е. прошла авторизация и имеем сессию на сервере с открытой страницей, затем не теряя сессию, в эту же страницу внедряем её же HTML содержимое + свой скрипт, который всё выгружает ? - я правильно понял ?</p>]]></description>
			<author><![CDATA[null@example.com (Евген)]]></author>
			<pubDate>Wed, 18 Apr 2012 15:42:39 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=59520#p59520</guid>
		</item>
		<item>
			<title><![CDATA[Re: Jscript:Доступ к логин странице]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=59482#p59482</link>
			<description><![CDATA[<p>OFF: Каждый Колумб открывают Америку заново...:) Только не &quot;токИны&quot;, а токЕны - tokens. )</p>]]></description>
			<author><![CDATA[null@example.com (Xameleon)]]></author>
			<pubDate>Wed, 18 Apr 2012 08:27:52 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=59482#p59482</guid>
		</item>
		<item>
			<title><![CDATA[Re: Jscript:Доступ к логин странице]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=59479#p59479</link>
			<description><![CDATA[<p>Возникла проблема с интернет-клиентом (ИК) необходимо выгружать все выписки за день. Счетов больше 400<br />ИК использует в качестве ключей токены и экспортирует выписки по одной. Аундефикация происходит по токену.<br />Используя свойство ie_DocumentComplete можно получил список url выписок.<br />Последовательно загружаем страницы в свой iframe для получения списка.<br />Список счетов-&gt;список выписок по каждому счету-&gt;нужная выписка</p><div class="codebox"><pre><code>function iFrame(url)
{
    if (ie.Document.all.vv) ie.Document.all.vv.outerHTML = &quot;&quot;;
    var html = &quot;&lt;iframe name=&#039;ifrPrint&#039; id=&#039;vv&#039; style=&#039;width:100%;height:0&#039; src=&quot;+url+&quot;&gt;&lt;/iframe&gt;&quot;;
    ie.Document.body.insertAdjacentHTML(&quot;beforeEnd&quot;, html);
}

iFrame(myurl)

function ie_DocumentComplete(iE,url)
{
if (url.indexOf(myurl)==0)
{
var a=iE.Document.getElementsByTagName(&quot;TD&quot;)
....
}
}</code></pre></div><p>Список url был получен. Каждый url вернет zip файл и если загрузить в iframe&nbsp; IExplorer каждый раз будет показывать окна<br />&quot;Сохранить как&quot; и &quot;Загрузка завершена&quot;. Для&nbsp; файлов &gt; 100 это большая проблема. </p><p>Если использовать в скрипте oXMLHTTP = CreateObject(&quot;MSXML2.XMLHTTP&quot;) то отправленный запрос не пройдет аундефикацию ИК. Что делать?</p><p>После долгих мучений нашел <strong>ВЫХОД</strong>:<br />Создаем объект <strong>Microsoft.XMLHTTP </strong>в <strong>InternetExplorer.Application </strong>c помощью <strong>динамического</strong> скрипта.<br /><strong>Созданный объект наследует свойства IE и прекрасно работает</strong></p><br /><div class="codebox"><pre><code>function ie_DocumentComplete(iE,url)
{
...
//var HttpReq = CreateObject(&quot;MSXML2.XMLHTTP&quot;)

var head = iE.Document.getElementsByTagName(&quot;head&quot;);
var script = iE.Document.createElement(&quot;script&quot;);
head[0].appendChild(script);
script.type = &quot;text/javascript&quot;;
script.text = &quot;  var myHTTP = new ActiveXObject(\&quot;Microsoft.XMLHTTP\&quot;);&quot;

for (var j=0; j&lt;Vip.length;j++)
{
var HttpReq = iE.Document.parentWindow.myHTTP
HttpReq.Open(&quot;GET&quot;,Vip[j],false)
HttpReq.send(null)
var File1 = new ActiveXObject(&quot;ADODB.Stream&quot;)
File1.Mode = 3
File1.Type = 1
File1.Open()
File1.Write(HttpReq.responseBody)
File1.SaveToFile(&quot;Vip&quot;+j+&quot;.zip&quot;,2)
File1.Close()
File1=null
}

.....</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (badik)]]></author>
			<pubDate>Wed, 18 Apr 2012 07:54:14 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=59479#p59479</guid>
		</item>
		<item>
			<title><![CDATA[Jscript:Доступ к логин странице]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=52870#p52870</link>
			<description><![CDATA[<p>Все чаще программы для аунтификации&nbsp; используют НТМЛ страницы.<br />К большому сожалению Логины в программе&nbsp; не совпадают с системными именами. Пришлось писать скрипты для заполнения&nbsp; логина пользователя.<br />Доступ к странице может осуществляется следующими способами:<br />&amp;#61485;	Страница загружается сразу<br />&amp;#61485;	Страница перегружается&nbsp; <br />&amp;#61485;	Станица загружается во фрейме</p><p>Страница загружается сразу <br /></p><div class="codebox"><pre><code>var ie = WScript.createObject(&#039;InternetExplorer.Application&#039;);
ie.visible = 1;
ie.navigate(&#039;http://Super_program1/login&#039;)
while (ie.Busy || (ie.READYSTATE != 4))
WScript.Sleep(100)

ie.document.all.userName.value = &quot;Super_&quot; + WScript.CreateObject(&quot;WScript.Network&quot;).UserName.toUpperCase()
while (ie.Busy || (ie.READYSTATE != 4))
WScript.Sleep(100)

ie.document.all.password.focus()
while (ie.Busy || (ie.READYSTATE != 4))
WScript.Sleep(100)</code></pre></div><p>Страница http://Super_program2/start&nbsp; перегружается. По этому будем использовать событие <strong>DocumentComplete</strong> ожидая загрузки нужной страницы http://Super_program2/login<br /></p><div class="codebox"><pre><code>var ie = WScript.createObject(&#039;InternetExplorer.Application&#039;, &quot;ie_&quot;);
ie.visible = 1;
ie.navigate(&#039;http://Super_program2/start&#039;)
while (ie.Busy || (ie.READYSTATE != 4))
WScript.Sleep(100)

var li = true

while (li) {
    if (!ie) {
        break;
    }
    WScript.Sleep(1000);
}

ie.document.all.usernameField.value = &quot;Super2_&quot; + WScript.CreateObject(&quot;WScript.Network&quot;).UserName.toUpperCase()
while (ie.Busy || (ie.READYSTATE != 4))
WScript.Sleep(100)
ie.document.all.passwordField.focus()
while (ie.Busy || (ie.READYSTATE != 4))
WScript.Sleep(100)

function ie_DocumentComplete(ie, url) {
    if (url.indexOf(&quot;http://Super_program2/login&quot;) == 0) {
        li = false
    }
}</code></pre></div><p>Станица загружается во фрейме. Перехват страницы осуществляем также как и в предыдущем случаи. Сохраняя ссылки на элементы диалога. Имена&nbsp; полей ввода разработчики выбрали оригинальные<br /></p><div class="codebox"><pre><code>var xL
var xP

var ie = WScript.createObject(&#039;InternetExplorer.Application&#039;, &quot;ie_&quot;);
ie.visible = 1;
ie.navigate(&#039;http://Super_program3/index&#039;)
while (ie.Busy || (ie.READYSTATE != 4))
WScript.Sleep(100)

var li = true
while (li) {
    if (!ie) {
        break;
    }
    WScript.Sleep(1000);
}


xL.value = WScript.CreateObject(&quot;WScript.Network&quot;).UserName.toLowerCase()
while (ie.Busy || (ie.READYSTATE != 4))
WScript.Sleep(100)
xP.focus()
while (ie.Busy || (ie.READYSTATE != 4))
WScript.Sleep(100)

function ie_DocumentComplete(ie, url) {
    if (url.indexOf(&quot;http://Super_program3/login&quot;) == 0) {
        var elements = ie.Document.getElementsByTagName(&#039;input&#039;)
        for (var i = 0; i &lt; elements.length; i++) {
            var element = elements[i];
            if (element.name == &#039;var/user.id&#039;) {
                xL = element
            }
            if (element.name == &#039;var/old.password&#039;) {
                xP = element
            }
        }
        li = false
    }
}</code></pre></div><p>Имена полей ввода удобно искать с помощью следующего скрипта являющегося хорошим примером использования&nbsp; событий&nbsp; InternetExplorer.Application<br /></p><div class="codebox"><pre><code>var ie = WScript.CreateObject(&quot;InternetExplorer.Application&quot;, &quot;ie_&quot;);
//----------------------------------------------------------

var console = {
  log: function(msg) {
    WScript.StdErr.Write(msg + &quot;\n&quot;);
  },

	event: function(operation, xpath, value)
	{
		var s = operation + &quot;,&quot; + xpath + &quot;,&quot; + value;
    WScript.StdErr.Write(s + &quot;\n&quot;);
	}

};
//----------------------------------------------------------
function ie_BeforeNavigate2(browser, url, flags, target, postdata, headers, cancel) {
  console.log(&quot;[event] BeforeNavigate2&quot;);
  console.log(&quot;document -&gt; &quot; + typeof ie.Document);

  with({ window: ie.Document.parentWindow }) {
    console.log(&quot;window -&gt; &quot; + typeof window);
  }
}
//----------------------------------------------------------
function ie_NavigateComplete2(ie, url) {
  console.log(&quot;[event] NavigateComplete2&quot;);
  console.log(&quot;document -&gt; &quot; + typeof ie.Document);
  with({ window: ie.Document.parentWindow }) {
    console.log(&quot;window -&gt; &quot; + typeof window);
  }
}
//----------------------------------------------------------
function ie_DocumentComplete(ie, url) {
	console.log(&quot;\n&quot;);
  console.log(&quot;[event] DocumentComplete = &quot; + url);
	console.log(&quot;TITLE = &quot; + ie.Document.title);
	console.log(&quot;\n&quot;);
	ie.Document.attachEvent(&#039;onclick&#039;, function() {
		console.log(&#039;onclick&#039;);
	});
	setEventHandler(ie.Document.getElementsByTagName(&#039;a&#039;));
	setEventHandler(ie.Document.getElementsByTagName(&#039;input&#039;));
	setEventHandler(ie.Document.getElementsByTagName(&#039;select&#039;));
	setEventHandler(ie.Document.getElementsByTagName(&#039;textarea&#039;));
}
//----------------------------------------------------------
function ie_NewWindow2()
{
  console.log(&quot;[event] NewWindow2&quot;);
}
//----------------------------------------------------------
function ie_NewWindow3()
{
  console.log(&quot;[event] NewWindow3&quot;);
}
//----------------------------------------------------------
function ie_OnQuit() {
  console.log(&quot;[event] OnQuit&quot;);
  ie = null;
}
//----------------------------------------------------------
function setEventHandler(elements)
{
	for (var i=0; i&lt;elements.length; i++) {
		var element = elements[i];
		element.attachEvent(&#039;onclick&#039;, eventHandler);
//		element.attachEvent(&#039;onfocus&#039;, eventHandler);
		element.attachEvent(&#039;onblur&#039;, eventHandler);
		element.attachEvent(&#039;onchange&#039;, eventHandler);
	}
}
//----------------------------------------------------------
function eventHandler(evt)
{
	console.event(
		evt.type,
		getElementLocation(evt.srcElement),
		getElementValue(evt.srcElement)
	);
}
//----------------------------------------------------------
function getElementLocation(element)
{
	var s = &#039;&#039;;
	var tagName = element.tagName.toLowerCase();
	if (element.id) {
//		return &#039;#&#039; + element.id;
	}
	switch (tagName) {
		case &#039;a&#039;:
			var t = element.innerText;
			if (t) {
				return tagName + &quot;[@href=&#039;&quot; + t + &quot;&#039;]&quot;;
			} else {
				var imgs = a.getElementsByTagName(&#039;img&#039;);
				if (0 &lt; imgs.length) {
					t = imgs[0].alt;
					return tagName + &quot;.img.alt=&#039;&quot; + t + &quot;&#039;]&quot;;
				}
			}
		break;
		case &#039;input&#039;:
			switch (element.type) {
				case &#039;radio&#039;:
				case &#039;checkbox&#039;:
					return tagName + &quot;[@name=&#039;&quot; + element.name + &quot;&#039; and @value=&#039;&quot; + element.value + &quot;&#039;]&quot;;
					break;
				default:
					return tagName + &quot;[@name=&#039;&quot; + element.name + &quot;&#039;]&quot;;
					break;
		}
	}

}
//----------------------------------------------------------
function getElementValue(element)
{
	var tagName = element.tagName.toLowerCase();

	switch (tagName) {
		case &#039;input&#039;:
			switch (element.type) {
				case &#039;radio&#039;:
				case &#039;checkbox&#039;:
					return element.checked;
					break;

				default:
					return element.value;
			}
			break;

		case &#039;textarea&#039;:
			return element.value;
			break;

		case &#039;select&#039;:
			break;

		case &#039;a&#039;:
			return element.href;
			break;
	}

}
//----------------------------------------------------------
function getElementBySelector(tagName, name)
{
	var elements = ie.Document.getElementsByTagName(tagName);
}
//----------------------------------------------------------


ie.Visible = true;
ie.Navigate2(&quot;http://ya.ru&quot;);
ie.width = 800;
ie.height = 1000;
while (ie.Busy || (ie.READYSTATE != 4))
WScript.Sleep(100)
//ie.visible=1;

while (true) {
  if (!ie) {
    break;
  }
  WScript.Sleep(1000);
}</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (badik)]]></author>
			<pubDate>Tue, 25 Oct 2011 04:19:38 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=52870#p52870</guid>
		</item>
	</channel>
</rss>
