#include <Array.au3>
#include <INet.au3>
Dim $aUrls[28][3] = [ ["http://anekdotov.net/anekdot/today.html", "<div align=justify>", "</div"], _
					 ["http://anekdotov.net/anekdot/", '<A NAME="\d+"></A>', "</div"], _
					 ["http://anekdotov.net/anekdot/day/", "</b></font>: ", "<table width"], _
					 ["http://anekdotov.net/anekdot/week/", "<b>\d+ место:</b>", "<table width"], _
					 ["http://anekdotov.net/anekdot/month/", "<b>\d+ место:</b>", "<table width"], _
					 ["http://anekdotov.net/anekdot/blonde/", "<p align=left>", "<table width"], _
					 ["http://anekdotov.net/anekdot/vk/", "<p align=left>", "<table width"], _
					 ["http://anekdotov.net/vovochka/", "<p align=left>", "<table width"], _
					 ["http://anekdotov.net/anekdot/gai/", "<p align=left>", "<table width"], _
					 ["http://anekdotov.net/anekdot/today/", "<p align=left>", "<table width"], _
					 ["http://anekdotov.net/intim/", "<p align=left>", "<table width"], _
					 ["http://anekdotov.net/anwar/", "<p align=left>", "<table width"], _
					 ["http://anekdotov.net/anekdot/med/", "<p align=left>", "<table width"], _
					 ["http://anekdotov.net/ancomp/", "<p align=left>", "<table width"], _
					 ["http://anekdotov.net/anekdot/crime/", "<p align=left>", "<table width"], _
					 ["http://anekdotov.net/anekdot/narkom/", "<p align=left>", "<table width"], _
					 ["http://anekdotov.net/anekdot/naci/", "<p align=left>", "<table width"], _
					 ["http://anekdotov.net/nr/", "<p align=left>", "<table width"], _
					 ["http://anekdotov.net/anekdot/porut/", "<p align=left>", "<table width"], _
					 ["http://anekdotov.net/anekdot/family/", "<p align=left>", "<table width"], _
					 ["http://anekdotov.net/anekdot/skazka/", "<p align=left>", "<table width"], _
					 ["http://anekdotov.net/sms/", "<p align=left>", "<table width"], _
					 ["http://anekdotov.net/anekdot/1001/", "<p align=left>\d+\. ", "<table width"], _
					 ["http://anekdotov.net/anekdot/student/", "<p align=left>", "<table width"], _
					 ["http://anekdotov.net/anekdot/chapai/", "<p align=left>", "<table width"], _
					 ["http://anekdotov.net/anekdot/black/", "<p align=left>", "<table width"], _
					 ["http://anekdotov.net/anekdot/boroda/", "<p align=left>", "<table width"], _
					 ["http://anekdotov.net/anekdot/other/", "<p align=left>", "<table width"] _
				  ]			; Массив ссылок, начало и конец анекдотов на каждой из страниц
_WriteToFile()
Func _WriteToFile($sFileName = @ScriptDir & '\Result.txt')
   Local $iRand = Random(0, UBound($aUrls) - 1, 1)										; Страница, с которой будем брать случайный текст
   Local $sHTML = _INetGetSource($aUrls[$iRand][0], True)								; Читаем в переменную исходник страницы
   If @error Then Exit MsgBox(4096, "", "Ошибка чтения страницы " & $aUrls[$iRand][0])
   Local $aList = StringRegExp($sHTML, '(?s)' & $aUrls[$iRand][1] & '(.+?)' & $aUrls[$iRand][2], 3)	; Массив анекдотов
   ;_ArrayDisplay($aList)
   $iRand = Random(0, UBound($aList) - 1, 1)										; Индекс случайного анекдота
   $aList[$iRand] = StringReplace($aList[$iRand], "—", '—')
   $aList[$iRand] = StringReplace($aList[$iRand], "
", @CRLF)
   $aList[$iRand] = StringReplace($aList[$iRand], "''", '"')
   $aList[$iRand] = StringRegExpReplace($aList[$iRand], "(?s)(<.+?>)", "")			; Несколько замен в коде страницы
   FileDelete($sFileName)
   FileWrite($sFileName, $aList[$iRand])											; Записываем в указанный файл
   ConsoleWrite($aList[$iRand] & @CRLF & '------------------' & @CRLF)
EndFunc