<?xml version='1.0' encoding="utf-8"?>
      <rss version='2.0'>
      <channel>
      <title>Форум на Исходниках.RU</title>
      <link>https://forum.sources.ru</link>
      <description>Форум на Исходниках.RU</description>
      <generator>Форум на Исходниках.RU</generator>
  	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=472374&amp;view=findpost&amp;p=3935047</guid>
        <pubDate>Tue, 27 Jan 2026 03:56:47 +0000</pubDate>
        <title>Обход CloudFlare</title>
        <link>https://forum.sources.ru/index.php?showtopic=472374&amp;view=findpost&amp;p=3935047</link>
        <description><![CDATA[salieri: <span class="b-attach" data-size="18899" data-hits="61" data-attach-id="67611" data-attach-post-id="3935047">
			<span class="b-attach__title"></span><a class='b-attach-link' href='https://forum.sources.ru/index.php?act=Attach&amp;type=post&amp;id=3935047&amp;attach_id=67611' title='Скачать файл' target='_blank'>excel_data_bridge_main.zip</a> (, : 61)
		</span><br>
<br>
Здравствуйте&#33;<br>
Решил для себя изучить криптовалюту, нашёл сайт ru.investing.com, хочу оттуда результаты индикаторов получать в режиме реального времени, но не знаю как обойти защиту.<br>
<br>
Если даже через браузер ввести <a class='tag-url' href='https://api.investing.com/api/financialdata/2186/historical/chart/' target='_blank'>https://api.investing.com/api/financialdata...storical/chart/</a>, то он даёт ошибку <div class='tag-code'><span class='pre_code'></span><div class='code  code_collapsed ' title='Подсветка синтаксиса доступна зарегистрированным участникам Форума.' style=''><div><div><ol type="1"><div class="code_line">[*]{&quot;@errors&quot;:[&quot;Core API respond with invalid status: 500&quot;]}</div></ol></div></div></div></div><script>preloadCodeButtons('1');</script><br>
<br>
Пытался через VB6 зайти на обычную страницу с индикаторами <a class='tag-url' href='https://ru.investing.com/crypto/bitcoin/technical' target='_blank'>https://ru.investing.com/crypto/bitcoin/technical</a>, но HTML-ответ через запрос GET отображается в сильно зашифрованном виде, что ничего не понять.<br>
А если ту же страницу открыть в браузере в виде HTML, то всё отлично.<br>
<br>
<div class='tag-code'><span class='pre_code'></span><div class='code  code_collapsed ' title='Подсветка синтаксиса доступна зарегистрированным участникам Форума.' style=''><div><div><ol type="1"><div class="code_line">Set http = CreateObject(&quot;MSXML2.XMLHTTP&quot;)</div><div class="code_line">&nbsp;</div><div class="code_line">http.Open &quot;GET&quot;, &quot;https://api.investing.com/api/financialdata/2186/historical/chart/&quot;, False</div><div class="code_line">&nbsp;</div><div class="code_line">http.setRequestHeader &quot;User-Agent&quot;, &quot;Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36&quot;</div><div class="code_line">http.setRequestHeader &quot;Accept-Language&quot;, &quot;ru-RU,ru;q=0.9,en-US;q=0.8,en;q=0.7&quot;</div><div class="code_line">http.setRequestHeader &quot;Accept-Encoding&quot;, &quot;gzip, deflate, br&quot;</div><div class="code_line">http.setRequestHeader &quot;Connection&quot;, &quot;keep-alive&quot;</div><div class="code_line">http.setRequestHeader &quot;DNT&quot;, &quot;1&quot;</div><div class="code_line">http.setRequestHeader &quot;Sec-Fetch-Dest&quot;, &quot;empty&quot;</div><div class="code_line">http.setRequestHeader &quot;Sec-Fetch-Mode&quot;, &quot;cors&quot;</div><div class="code_line">http.setRequestHeader &quot;Sec-Fetch-Site&quot;, &quot;same-origin&quot;</div><div class="code_line">http.setRequestHeader &quot;interval&quot;, &quot;PT1M&quot;</div><div class="code_line">http.setRequestHeader &quot;pointscount&quot;, &quot;160&quot;</div><div class="code_line">http.Send</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</div><div class="code_line">fs_input = http.ResponseText</div><div class="code_line">Set http = Nothing</div></ol></div></div></div></div><br>
<br>
<br>
Нашёл пример на Python, но там спец. библиотеки, я с ним плохо знаком, поэтому не могу ничего понять.<br>
<br>
Отрывок из кода программы:<br>
<div class='tag-code'><span class='pre_code'></span><div class='code  code_collapsed ' title='Подсветка синтаксиса доступна зарегистрированным участникам Форума.' style=''><div><div><ol type="1"><div class="code_line">&nbsp;class InvestingParser:</div><div class="code_line">&nbsp;&nbsp; &nbsp;def __init__(self):</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;self.user_agents = [</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&#39;Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36&#39;,</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&#39;Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36&#39;,</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;]</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;self.session = None</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;self.init_session()</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp;def init_session(self):</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;self.session = requests.Session()</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;user_agent = random.choice(self.user_agents)</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;headers = {</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&#39;User-Agent&#39;: user_agent, &#39;Accept&#39;: &#39;application/json, text/javascript, */*; q=0.01&#39;,</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&#39;Accept-Language&#39;: &#39;ru-RU,ru;q=0.9,en-US;q=0.8,en;q=0.7&#39;, &#39;Accept-Encoding&#39;: &#39;gzip, deflate, br&#39;,</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&#39;Connection&#39;: &#39;keep-alive&#39;, &#39;DNT&#39;: &#39;1&#39;, &#39;Sec-Fetch-Dest&#39;: &#39;empty&#39;, &#39;Sec-Fetch-Mode&#39;: &#39;cors&#39;,</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&#39;Sec-Fetch-Site&#39;: &#39;same-origin&#39;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;}</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;self.session.headers.update(headers)</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;from requests.adapters import HTTPAdapter</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;from urllib3.util.retry import Retry</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;retry_strategy = Retry(total=3, backoff_factor=1, status_forcelist=[429, 500, 502, 503, 504])</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;adapter = HTTPAdapter(max_retries=retry_strategy)</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;self.session.mount(&quot;https://&quot;, adapter)</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp;def try_cloudscraper(self):</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;try:</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;import cloudscraper</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;logging.info(&quot;Используем cloudscraper для обхода CloudFlare...&quot;)</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;scraper = cloudscraper.create_scraper()</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;url = &quot;https://api.investing.com/api/financialdata/2186/historical/chart/&quot;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;params = {&#39;interval&#39;: &#39;PT1M&#39;, &#39;pointscount&#39;: &#39;160&#39;}</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;response = scraper.get(url, params=params, timeout=30)</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if response.status_code == 200:</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;return self.process_data(response.json())</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;return {&#39;error&#39;: f&#39;HTTP Error {response.status_code}&#39;}</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;except Exception as e:</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;logging.error(f&quot;Ошибка CloudScraper: {str(e)}&quot;)</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;return {&#39;error&#39;: f&#39;CloudScraper error: {str(e)}&#39;}</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp;def try_requests(self):</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;try:</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;logging.info(&quot;Пробуем прямой запрос через requests...&quot;)</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;url = &quot;https://api.investing.com/api/financialdata/2186/historical/chart/&quot;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;params = {&#39;interval&#39;: &#39;PT1M&#39;, &#39;pointscount&#39;: &#39;160&#39;}</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;response = self.session.get(url, params=params, timeout=30)</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if response.status_code == 200:</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;return self.process_data(response.json())</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;return {&#39;error&#39;: f&#39;HTTP Error {response.status_code}&#39;}</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;except Exception as e:</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;logging.error(f&quot;Ошибка requests: {str(e)}&quot;)</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;return {&#39;error&#39;: f&#39;Requests error: {str(e)}&#39;}</div></ol></div></div></div></div><br>
<br>
Саму программу скачивал здесь: <a class='tag-url' href='https://github.com/empenoso/excel-data-bridge' target='_blank'>https://github.com/empenoso/excel-data-bridge</a><br>
Прикрепил ZIP-архив к теме.]]></description>
        <author>salieri</author>
        <category>Visual Basic: Общие вопросы</category>
      </item>
	
      </channel>
      </rss>
	