<?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=39882&amp;view=findpost&amp;p=258540</guid>
        <pubDate>Sat, 06 Dec 2003 06:11:11 +0000</pubDate>
        <title>Существует URL ?</title>
        <link>https://forum.sources.ru/index.php?showtopic=39882&amp;view=findpost&amp;p=258540</link>
        <description><![CDATA[Song: Данная функция позволяет Вам проверить существование определённого адреса(URL) в интернете. Естественно она может пригодиться веб-мастерам, у которых на сайте много ссылок, и необходимо с определённой периодичнойстью эти ссылки проверять. <br><br>URL может быть как с префиксом http:/ так и без него - эта функция добавляет префикс http:// если он отсутствует (необходимо для функции internetOpenUrl которая так же поддерживает FTP:// и gopher:// <br><br>Эта функция проверяет только два возвращаемых кода &#39;200&#39;(ОК) или &#39;302&#39; (Редирект), но Вы можете заставить проверять функцию и другие коды. Для этого достаточно модифицировать строчку &quot;result := &quot;. <br><br>Платформа: Delphi 3.x (или выше)<br><br><!--c1--></div><table border='0' align='center' width='95%' cellpadding='3' cellspacing='1'><tr><td><b></b> </td></tr><tr><td id='CODE'><!--ec1-->uses wininet; <br><br>Function CheckUrl&#40;url&#58;string&#41;&#58;boolean; <br>var <br>hSession, hfile, hRequest&#58; hInternet; <br>dwindex,dwcodelen &#58;dword; <br>dwcode&#58;array&#91;1..20&#93; of char; <br>res &#58; pchar; <br>begin <br> &nbsp;if pos&#40;&#39;http&#58;//&#39;,lowercase&#40;url&#41;&#41;=0 then <br> &nbsp; &nbsp; url &#58;= &#39;http&#58;//&#39;+url; <br> &nbsp;Result &#58;= false; <br> &nbsp;hSession &#58;= InternetOpen&#40;&#39;InetURL&#58;/1.0&#39;, <br> &nbsp; &nbsp; &nbsp; INTERNET_OPEN_TYPE_PRECONFIG,nil, nil, 0&#41;; <br> &nbsp;if assigned&#40;hsession&#41; then <br> &nbsp; &nbsp;begin <br> &nbsp; &nbsp; &nbsp;hfile &#58;= InternetOpenUrl&#40; <br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; hsession, <br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; pchar&#40;url&#41;, <br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; nil, <br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 0, <br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; INTERNET_FLAG_RELOAD, <br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 0&#41;; <br> &nbsp; &nbsp; &nbsp;dwIndex &nbsp;&#58;= 0; <br> &nbsp; &nbsp; &nbsp;dwCodeLen &#58;= 10; <br> &nbsp; &nbsp; &nbsp;HttpQueryInfo&#40;hfile, HTTP_QUERY_STATUS_CODE, <br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;@dwcode, dwcodeLen, dwIndex&#41;; <br> &nbsp; &nbsp; &nbsp;res &#58;= pchar&#40;@dwcode&#41;; <br> &nbsp; &nbsp; &nbsp;result&#58;= &#40;res =&#39;200&#39;&#41; or &#40;res =&#39;302&#39;&#41;; <br> &nbsp; &nbsp; &nbsp;if assigned&#40;hfile&#41; then <br> &nbsp; &nbsp; &nbsp; &nbsp;InternetCloseHandle&#40;hfile&#41;; <br> &nbsp; &nbsp; &nbsp;InternetCloseHandle&#40;hsession&#41;; <br> &nbsp; &nbsp;end; <br> &nbsp; <br>end;<!--c2--></td></tr></table><div class='postcolor'><!--ec2-->]]></description>
        <author>Song</author>
        <category>Интернет, сети, протоколы</category>
      </item>
	
      </channel>
      </rss>
	