<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title><![CDATA[Серый форум &mdash; AHK: Получить текст с HTML страницы в переменную]]></title>
		<link>http://forum.script-coding.com/viewtopic.php?id=9394</link>
		<atom:link href="http://forum.script-coding.com/extern.php?action=feed&amp;tid=9394&amp;type=rss" rel="self" type="application/rss+xml" />
		<description><![CDATA[Недавние сообщения в теме «AHK: Получить текст с HTML страницы в переменную».]]></description>
		<lastBuildDate>Mon, 21 May 2018 21:39:18 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Re: AHK: Получить текст с HTML страницы в переменную]]></title>
			<link>http://forum.script-coding.com/viewtopic.php?pid=125527#p125527</link>
			<description><![CDATA[<p>Получается, это пустая строка создавала ошибку). Спасибо!</p>]]></description>
			<author><![CDATA[null@example.com (DD)]]></author>
			<pubDate>Mon, 21 May 2018 21:39:18 +0000</pubDate>
			<guid>http://forum.script-coding.com/viewtopic.php?pid=125527#p125527</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Получить текст с HTML страницы в переменную]]></title>
			<link>http://forum.script-coding.com/viewtopic.php?pid=125526#p125526</link>
			<description><![CDATA[<p>Замените<br /></p><div class="codebox"><pre><code>msgbox % api_lst_index</code></pre></div><p>на<br /></p><div class="codebox"><pre><code>msgbox %A_Index% ссылка которая отправляется в функцию`n &quot;%api_lst_index%&quot;</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (Malcev)]]></author>
			<pubDate>Mon, 21 May 2018 21:29:43 +0000</pubDate>
			<guid>http://forum.script-coding.com/viewtopic.php?pid=125526#p125526</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Получить текст с HTML страницы в переменную]]></title>
			<link>http://forum.script-coding.com/viewtopic.php?pid=125525#p125525</link>
			<description><![CDATA[<p>Отправляю рабочую ссылку:<br /></p><div class="codebox"><pre><code>loop % 1 + 1 // 1 
      api_lst .= &quot;https://vk.com/al_wall.php?act=get_replies&amp;al=1&amp;count=1&amp;from=wkview&amp;offset=&quot; (A_index - 1) * 1 &quot;&amp;post=1_2285269&amp;rev=0&quot; &quot;`n&quot;

Loop, parse, api_lst, `n
{
api_lst_index := A_LoopField
msgbox % api_lst_index
api_lst_index := UrlDownloadToVar(api_lst_index)
All_api_lst_vars .= api_lst_index
}
MsgBox % All_api_lst_vars &quot;`n`n`n&quot;
return

UrlDownloadToVar(URL, UserAgent = &quot;&quot;)
{
   WebRequest := ComObjCreate(&quot;WinHttp.WinHttpRequest.5.1&quot;)
   WebRequest.Open(&quot;GET&quot;, Url)
   UserAgent ? WebRequest.Option(WinHttpRequestOption_UserAgentString := 0) := UserAgent
   WebRequest.Send()
   Text := WebRequest.ResponseText
   WebRequest := &quot;&quot;
   return Text
}</code></pre></div><p>Но если заменить первые две строки (в которых ссылки составляются программно), на следующий фрагмент (где эти же ссылки находятся в переменной), — всё скачается: <br /></p><div class="codebox"><pre><code>api_lst=
(
https://vk.com/al_wall.php?act=get_replies&amp;al=1&amp;count=1&amp;from=wkview&amp;offset=0&amp;post=1_2285269&amp;rev=0
https://vk.com/al_wall.php?act=get_replies&amp;al=1&amp;count=1&amp;from=wkview&amp;offset=1&amp;post=1_2285269&amp;rev=0
)</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (DD)]]></author>
			<pubDate>Mon, 21 May 2018 21:20:22 +0000</pubDate>
			<guid>http://forum.script-coding.com/viewtopic.php?pid=125525#p125525</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Получить текст с HTML страницы в переменную]]></title>
			<link>http://forum.script-coding.com/viewtopic.php?pid=125523#p125523</link>
			<description><![CDATA[<p>Так вставьте msgbox и посмотрите, что отправляете функции.</p>]]></description>
			<author><![CDATA[null@example.com (Malcev)]]></author>
			<pubDate>Mon, 21 May 2018 20:57:44 +0000</pubDate>
			<guid>http://forum.script-coding.com/viewtopic.php?pid=125523#p125523</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Получить текст с HTML страницы в переменную]]></title>
			<link>http://forum.script-coding.com/viewtopic.php?pid=125522#p125522</link>
			<description><![CDATA[<p>Неужели нельзя через UrlDownloadToVar скачать составленные в коде ссылки?</p>]]></description>
			<author><![CDATA[null@example.com (DD)]]></author>
			<pubDate>Mon, 21 May 2018 20:41:44 +0000</pubDate>
			<guid>http://forum.script-coding.com/viewtopic.php?pid=125522#p125522</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Получить текст с HTML страницы в переменную]]></title>
			<link>http://forum.script-coding.com/viewtopic.php?pid=125506#p125506</link>
			<description><![CDATA[<p>Третий час не могу понять, почему, когда ссылки генерируются из скрипта — UrlDownloadToVar завершается ошибкой, —<br /></p><div class="codebox"><pre><code>#SingleInstance Force

   step := 1
   lnk_1 := &quot;https://vk.com/al_wall.php?act=get_replies&amp;al=1&amp;count=1&amp;from=wkview&amp;offset=&quot;
   lnk_2 := &quot;&amp;post=1_2285269&amp;rev=0&quot;

   loop % 1 + 1 // step 
      api_lst .= lnk_1 (A_index - 1) * step lnk_2 &quot;`n&quot;

msgbox % api_lst

api_lst := RegExReplace(api_lst,&quot;\R+&quot;,&quot;`n&quot;)

Loop, parse, api_lst, `n
{
api_lst_index := A_LoopField
api_lst_index := UrlDownloadToVar(api_lst_index)
All_api_lst_vars .= api_lst_index
}
MsgBox % All_api_lst_vars &quot;`n`n`n&quot;
return

UrlDownloadToVar(URL, UserAgent = &quot;&quot;)
{
   WebRequest := ComObjCreate(&quot;WinHttp.WinHttpRequest.5.1&quot;)
   WebRequest.Open(&quot;GET&quot;, Url)
   UserAgent ? WebRequest.Option(WinHttpRequestOption_UserAgentString := 0) := UserAgent
   WebRequest.Send()
   Text := WebRequest.ResponseText
   WebRequest := &quot;&quot;
   return Text
}</code></pre></div><p>а когда те же ссылки даны в переменной в явном виде — скачивает? —<br /></p><div class="codebox"><pre><code>#SingleInstance Force

api_lst=
(
https://vk.com/al_wall.php?act=get_replies&amp;al=1&amp;count=1&amp;from=wkview&amp;offset=0&amp;post=1_2285269&amp;rev=0
https://vk.com/al_wall.php?act=get_replies&amp;al=1&amp;count=1&amp;from=wkview&amp;offset=1&amp;post=1_2285269&amp;rev=0
)
api_lst := RegExReplace(api_lst,&quot;\R+&quot;,&quot;`n&quot;)

Loop, parse, api_lst, `n
{
api_lst_index := A_LoopField
api_lst_index := UrlDownloadToVar(api_lst_index)
All_api_lst_vars .= api_lst_index
}
MsgBox % All_api_lst_vars &quot;`n`n`n&quot;
return

UrlDownloadToVar(URL, UserAgent = &quot;&quot;)
{
   WebRequest := ComObjCreate(&quot;WinHttp.WinHttpRequest.5.1&quot;)
   WebRequest.Open(&quot;GET&quot;, Url)
   UserAgent ? WebRequest.Option(WinHttpRequestOption_UserAgentString := 0) := UserAgent
   WebRequest.Send()
   Text := WebRequest.ResponseText
   WebRequest := &quot;&quot;
   return Text
}</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (DD)]]></author>
			<pubDate>Mon, 21 May 2018 13:20:45 +0000</pubDate>
			<guid>http://forum.script-coding.com/viewtopic.php?pid=125506#p125506</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Получить текст с HTML страницы в переменную]]></title>
			<link>http://forum.script-coding.com/viewtopic.php?pid=123960#p123960</link>
			<description><![CDATA[<p><span style="color: green"><strong>MrRutts</strong> оформите код тегом &quot;code&quot;:<br /><a href="http://forum.script-coding.com/viewtopic.php?pid=123943#p123943">http://forum.script-coding.com/viewtopi … 43#p123943</a>,<br /><a href="http://forum.script-coding.com/viewtopic.php?pid=123918#p123918">http://forum.script-coding.com/viewtopi … 18#p123918</a>.</span></p><p><span style="color: green"><strong>qqlexa</strong>, оформите ссылки тегом &quot;url&quot;.<br /><a href="http://forum.script-coding.com/viewtopic.php?pid=123917#p123917">http://forum.script-coding.com/viewtopi … 17#p123917</a></span><br /><span style="color: green"><a href="http://forum.script-coding.com/viewtopic.php?pid=123856#p123856">http://forum.script-coding.com/viewtopi … 56#p123856</a></span><br /><span style="color: green"><a href="http://forum.script-coding.com/viewtopic.php?pid=123852#p123852">http://forum.script-coding.com/viewtopi … 52#p123852</a></span><br /><span style="color: green"><a href="http://forum.script-coding.com/viewtopic.php?pid=123851#p123851">http://forum.script-coding.com/viewtopi … 51#p123851</a></span><br /><span style="color: green"><a href="http://forum.script-coding.com/viewtopic.php?pid=123850#p123850">http://forum.script-coding.com/viewtopi … 50#p123850</a></span><br /><span style="color: green"><a href="http://forum.script-coding.com/viewtopic.php?pid=123849#p123849">http://forum.script-coding.com/viewtopi … 49#p123849</a></span><br /><span style="color: green"><a href="http://forum.script-coding.com/viewtopic.php?pid=123848#p123848">http://forum.script-coding.com/viewtopi … 48#p123848</a></span><br /><span style="color: green"><a href="http://forum.script-coding.com/viewtopic.php?pid=123846#p123846">http://forum.script-coding.com/viewtopi … 46#p123846</a></span></p>]]></description>
			<author><![CDATA[null@example.com (ypppu)]]></author>
			<pubDate>Tue, 06 Mar 2018 17:01:23 +0000</pubDate>
			<guid>http://forum.script-coding.com/viewtopic.php?pid=123960#p123960</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Получить текст с HTML страницы в переменную]]></title>
			<link>http://forum.script-coding.com/viewtopic.php?pid=123945#p123945</link>
			<description><![CDATA[<p><strong>stealzy</strong>, я даже не подумал, что для чтения данных ему необходима авторизация, т.к. сам то уже вошел, и визуально вижу сайт).<br />Спасибо за направление, буду мурыжить дальше!</p>]]></description>
			<author><![CDATA[null@example.com (MrRutts)]]></author>
			<pubDate>Tue, 06 Mar 2018 03:01:15 +0000</pubDate>
			<guid>http://forum.script-coding.com/viewtopic.php?pid=123945#p123945</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Получить текст с HTML страницы в переменную]]></title>
			<link>http://forum.script-coding.com/viewtopic.php?pid=123944#p123944</link>
			<description><![CDATA[<p><strong>MrRutts</strong>, во-первых для передачи в ф-ию строки нужно обрамлять кавычками.<br />Во-вторых, вы уверены что на данной странице это число есть <img src="//forum.script-coding.com/img/smilies/smile.png" width="15" height="15" />? Я вот уверен, что нет, потому что нужно сначала залогинится на сайте.<br />Можете посмотреть темы по автоматизации браузера с помощью <span style="color: grey">ComObjCreate(&quot;WinHttp.WinHttpRequest.5.1&quot;)</span>. RegEx кстати не обязателен, можно извлекать значение по классу элемента.</p>]]></description>
			<author><![CDATA[null@example.com (stealzy)]]></author>
			<pubDate>Tue, 06 Mar 2018 02:34:39 +0000</pubDate>
			<guid>http://forum.script-coding.com/viewtopic.php?pid=123944#p123944</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Получить текст с HTML страницы в переменную]]></title>
			<link>http://forum.script-coding.com/viewtopic.php?pid=123943#p123943</link>
			<description><![CDATA[<p><strong>qqlexa</strong>, спасибо, действительно верное для меня направление!<br />Но ввиду отсутствия должных навыков, не могу правильно применить функцию:</p><br /><br /><p>text := UrlDownloadToVar(&quot;https://binomo.com/ru/trading&quot;)<br />Msgbox % RegExReplace(text, &lt;span class=&quot;currency-amount ng-binding&quot; ng-bind=&quot;vm.amount$ | async:this&quot;&gt;, &quot; &lt;/span&gt;&quot; )</p><p>UrlDownloadToVar(URL, UserAgent = &quot;&quot;)<br />{<br />&nbsp; &nbsp;WebRequest := ComObjCreate(&quot;WinHttp.WinHttpRequest.5.1&quot;)<br />&nbsp; &nbsp;WebRequest.Open(&quot;GET&quot;, Url)<br />&nbsp; &nbsp;UserAgent ? WebRequest.Option(WinHttpRequestOption_UserAgentString := 0) := UserAgent<br />&nbsp; &nbsp;WebRequest.Send()<br />&nbsp; &nbsp;Text := WebRequest.ResponseText<br />&nbsp; &nbsp;WebRequest := &quot;&quot;<br />&nbsp; &nbsp;return Text<br />}</p><p>Должен принять число 1068,94:</p><p>&lt;span class=&quot;currency-amount ng-binding&quot; ng-bind=&quot;vm.amount$ | async:this&quot;&gt;1 068,94 &lt;/span&gt;</p><p>но msgbox выдает пустоту.</p>]]></description>
			<author><![CDATA[null@example.com (MrRutts)]]></author>
			<pubDate>Tue, 06 Mar 2018 02:02:06 +0000</pubDate>
			<guid>http://forum.script-coding.com/viewtopic.php?pid=123943#p123943</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Получить текст с HTML страницы в переменную]]></title>
			<link>http://forum.script-coding.com/viewtopic.php?pid=123917#p123917</link>
			<description><![CDATA[<p><strong>MrRutts</strong> Используй RegExMatch <a href="http://%20http://www.script-coding.com/AutoHotkey/RegExMatch.html"> http://www.script-coding.com/AutoHotke … Match.html</a> .</p>]]></description>
			<author><![CDATA[null@example.com (qqlexa)]]></author>
			<pubDate>Mon, 05 Mar 2018 08:10:19 +0000</pubDate>
			<guid>http://forum.script-coding.com/viewtopic.php?pid=123917#p123917</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Получить текст с HTML страницы в переменную]]></title>
			<link>http://forum.script-coding.com/viewtopic.php?pid=123915#p123915</link>
			<description><![CDATA[<p><strong>Добрый день!</strong><br />Сразу оговорю, я полный новичок в АНК, потому для Вас возможно это вполне рядовая задача, а для меня полный тупик.<br />Подскажите, как средствами АНК выловить значение 1068,94 и открыть текстовый блокнот, записать, сохранить и закрыть. Естественно, значение постоянно будет меняться, нужно ловить тэгами. Пробовал все вышеуказанные способы, но msgbox постоянно выходит пустым.<br />&lt;span class=&quot;currency-amount ng-binding&quot; ng-bind=&quot;vm.amount$ | async:this&quot;&gt;1 068,94 &lt;/span&gt;</p>]]></description>
			<author><![CDATA[null@example.com (MrRutts)]]></author>
			<pubDate>Mon, 05 Mar 2018 07:27:18 +0000</pubDate>
			<guid>http://forum.script-coding.com/viewtopic.php?pid=123915#p123915</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Получить текст с HTML страницы в переменную]]></title>
			<link>http://forum.script-coding.com/viewtopic.php?pid=122091#p122091</link>
			<description><![CDATA[<p>Получаете коллекцию элементов.<br />Выбираете нужный вам элемент.<br />В начале темы <strong>Xameleon</strong> объяснял, как это делать.</p>]]></description>
			<author><![CDATA[null@example.com (Malcev)]]></author>
			<pubDate>Sat, 09 Dec 2017 02:27:56 +0000</pubDate>
			<guid>http://forum.script-coding.com/viewtopic.php?pid=122091#p122091</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Получить текст с HTML страницы в переменную]]></title>
			<link>http://forum.script-coding.com/viewtopic.php?pid=122088#p122088</link>
			<description><![CDATA[<p>А как быть с одинаковыми элементами?<br /><a href="http://prntscr.com/hl1t1w">http://prntscr.com/hl1t1w</a><br /></p><div class="codebox"><pre><code>&lt;td class=&quot;number sorting_1&quot;&gt;0.02530089&lt;/td&gt;</code></pre></div><p><a href="https://bitconnect.co/user/trade?Market=BCC">https://bitconnect.co/user/trade?Market=BCC</a><br />Нужно в переменную извлекать только данные из первой строчки самого левого столбца как на скриншоте.</p>]]></description>
			<author><![CDATA[null@example.com (Странникх)]]></author>
			<pubDate>Sat, 09 Dec 2017 01:50:25 +0000</pubDate>
			<guid>http://forum.script-coding.com/viewtopic.php?pid=122088#p122088</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Получить текст с HTML страницы в переменную]]></title>
			<link>http://forum.script-coding.com/viewtopic.php?pid=115456#p115456</link>
			<description><![CDATA[<p>Да, действительно, нету смысла указывать.<br />Я что-то сразу не подумал, что при ответе 304, Response Body не возврашается.<br /></p><div class="codebox"><pre><code>url := &quot;https://autohotkey.com/download/1.1/version.txt&quot;
HTTP := ComObjCreate(&quot;WinHTTP.WinHTTPRequest.5.1&quot;)
HTTP.Open(&quot;GET&quot;, url)
HTTP.Send()
date:= HTTP.getResponseHeader(&quot;Last-Modified&quot;)
msgbox % HTTP.Status
msgbox % HTTP.ResponseText
HTTP.Open(&quot;GET&quot;, url)
HTTP.SetRequestHeader(&quot;If-Modified-Since&quot;, date)
HTTP.Send()
msgbox % HTTP.Status
msgbox % HTTP.ResponseText</code></pre></div><p>А в справке по автохотки в примере получается недочет.<br /></p><div class="codebox"><pre><code> Example: Make an asynchronous HTTP request.

req := ComObjCreate(&quot;Msxml2.XMLHTTP&quot;)
; Open a request with async enabled.
req.open(&quot;GET&quot;, &quot;https://autohotkey.com/download/1.1/version.txt&quot;, true)
; Set our callback function (v1.1.17+).
req.onreadystatechange := Func(&quot;Ready&quot;)
; Send the request.  Ready() will be called when it&#039;s complete.
req.send()
/*
; If you&#039;re going to wait, there&#039;s no need for onreadystatechange.
; Setting async=true and waiting like this allows the script to remain
; responsive while the download is taking place, whereas async=false
; will make the script unresponsive.
while req.readyState != 4
    sleep 100
*/
#Persistent

Ready() {
    global req
    if (req.readyState != 4)  ; Not done yet.
        return
    if (req.status == 200 || req.status == 304) ; OK.
        MsgBox % &quot;Latest AutoHotkey version: &quot; req.responseText
    else
        MsgBox 16,, % &quot;Status &quot; req.status
    ExitApp
}</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (Malcev)]]></author>
			<pubDate>Sat, 29 Apr 2017 10:57:11 +0000</pubDate>
			<guid>http://forum.script-coding.com/viewtopic.php?pid=115456#p115456</guid>
		</item>
	</channel>
</rss>
