51 (изменено: DD, 2018-05-11 23:48:15)

Re: AHK: Скачивание через GET/POST-запросы

Круто, спасибо! Можно ли будет задать игнорируемые символы — в частности, угловые скобки (тэги), а то они переделываются в <>? Или может имеется код, преобразующий юникод в готовые символы, как есть? —

\u2026   —>   
\u201d   —>   

52 (изменено: DD, 2018-05-11 23:59:52)

Re: AHK: Скачивание через GET/POST-запросы

Нашёл)) —

HTM =
(
<p>Your comment is correct, and I would like to add more&#8230; Crucifixion was not only a death sentence, but a form of cruel torture that sometimes took days for one to die as the individual endured excruciation pain beforehand&#8230; The scribes, and Pharisee&#8217;s who hated Jesus (not all did), wanted to humiliate our Savior to the utmost while demanding that the Roman governor Pilate execute HIM in this manner&#8230; Of course scripture had to fulfilled, but never the less, their hatred for Jesus was nothing more than Satanically inspired&#8230; </p>
<p>The cross is a pagan symbol that was used to honor Tammuz&#8230; The ancient son of Semiramis, who was worshiped by many as a goddess&#8230; Thus making her son a god in the eyes of the population&#8230; The ancient Israelites were shown to be worshiping Tammuz in the temple of God by weeping for this false god within Ezekiel chapter 8&#8230;<br />
&#8220;13 And He said to me, \u201cTurn again, and you will see greater abominations that they are doing.\u201d 14 So He brought me to the door of the north gate of the Lord\u2019s house; and to my dismay, women were sitting there weeping for Tammuz.&#8221;</p>
<p>Crucifixion was basically a sacrifice to the so called god Tammuz&#8230; Thus the scribes, and Pharisee&#8217;s were trying their best to discredit the Son of God&#8230; But it does not matter what these man thought, or imagined, that sacrifice of our Savior (the perfect Lamb of God) was necessary for the redemption of mankind&#8217;s sins&#8230; Only through HIM is anyone forgiven for the remission of sin&#8230;
)
HTM := JavaEscapedToHtml(HTM)
HTM := UnHTM(HTM)
msgbox % HTM


JavaEscapedToHtml(s) {
    i := 1
    while j := RegExMatch(s, "\\u[A-Fa-f0-9]{1,4}", m, i)
        e .= SubStr(s, i, j-i) Chr("0x" SubStr(m, 3)), i := j + StrLen(m)
    Transform, OutputVar, HTML, % e . SubStr(s, i)
    return OutputVar
}

UnHTM( HTM ) { ; Remove HTML formatting / Convert to ordinary text     by SKAN 19-Nov-2009
   Static HT     ; Forum Topic: www.autohotkey.com/forum/topic51342.html
   IfEqual,HT,,   SetEnv,HT, % "&aacuteá&acircâ&acute´&aeligæ&agraveà&amp&aringå&atildeã&au"
 . "mlä&bdquo„&brvbar¦&bull•&ccedilç&cedil¸&cent¢&circˆ&copy©&curren¤&dagger†&dagger‡&deg"
 . "°&divide÷&eacuteé&ecircê&egraveè&ethð&eumlë&euro€&fnofƒ&frac12½&frac14¼&frac34¾&gt>&h"
 . "ellip…&iacuteí&icircî&iexcl¡&igraveì&iquest¿&iumlï&laquo«&ldquo“&lsaquo‹&lsquo‘&lt<&m"
 . "acr¯&mdash—&microµ&middot·&nbsp &ndash–&not¬&ntildeñ&oacuteó&ocircô&oeligœ&ograveò&or"
 . "dfª&ordmº&oslashø&otildeõ&oumlö&para¶&permil‰&plusmn±&pound£&quot""&raquo»&rdquo”&reg"
 . "®&rsaquo›&rsquo’&sbquo‚&scaronš&sect§&shy&sup1¹&sup2²&sup3³&szligß&thornþ&tilde˜&tim"
 . "es×&trade™&uacuteú&ucircû&ugraveù&uml¨&uumlü&yacuteý&yen¥&yumlÿ"

   HTM := RegExReplace( HTM,"&amp;(\w+;)", "&$1" )   ;!! для обработки &amp;lt; 
   HTM := RegExReplace( HTM,"&amp;(#\d+;)", "&$1" )  ;!! для обработки &amp;#60;

   TXT := RegExReplace( HTM,"<[^>]+>", " " )               ; Remove all tags between  "<" and ">"
   Loop, Parse, TXT, &`;                              ; Create a list of special characters
      L := "&" A_LoopField ";", R .= (!(A_Index&1)) ? ( (!InStr(R,L,1)) ? L:"" ) : ""
   StringTrimRight, R, R, 1
   Loop, Parse, R , `;                                ; Parse Special Characters
      If F := InStr( HT, A_LoopField )                  ; Lookup HT Data
         StringReplace, TXT,TXT, %A_LoopField%`;, % SubStr( HT,F+StrLen(A_LoopField), 1 ), All
   Else If ( SubStr( A_LoopField,2,1)="#" )
      StringReplace, TXT, TXT, %A_LoopField%`;, % Chr(SubStr(A_LoopField,3)), All

   TXT := RegExReplace(TXT, " +", " ")       ;!! множественные пробелы на один
   TXT := RegExReplace(TXT, "m)(*UCP)(?<=\s|^)""(?=\w)", "«")      ;!! кавычки
   TXT := RegExReplace(TXT, "m)(*UCP)(?<=[^\s""])""(?=\W|$)", "»") ;!! кавычки

;!! кавычки
loop, 10
{
      TXT := RegExReplace(TXT, "«([^«»]*)«([^«»]*)»", "«$1«$2»")
      TXT := RegExReplace(TXT, " ""([\s?\)\]\}\,\.\:\;\!\?…""'])", "n~b~s~p""$1")
      TXT := RegExReplace(TXT, "((^|[\s]|&nbsp;)([\(\[\{""]|\d+)*)([""])(\S([^""]*?|.*?\x20[""]\x20.*?)\S|[^""\s])[""]((\d+|[\)\]\}\,\.\:\;\!\?…""])*($|[\s]|&nbsp;))", "$1«$5»$7")
      TXT := RegExReplace(TXT, "n~b~s~p", " ")
      TXT := RegExReplace(TXT, "«([^«»]*)«([^«»]*)»", "«$1„$2“")
}

   Return RegExReplace( TXT, "(^\s*|\s*$)")            ; Remove leading/trailing white spaces
}

53 (изменено: Malcev, 2018-05-12 02:14:28)

Re: AHK: Скачивание через GET/POST-запросы

DD пишет:

Или может имеется код, преобразующий юникод в готовые символы, как есть? —

msgbox % JavaEscapedToHtml("\u2026test\u00bb")

JavaEscapedToHtml(s) {
    i := 1
    while j := RegExMatch(s, "\\u[A-Fa-f0-9]{1,4}", m, i)
        e .= SubStr(s, i, j-i) Chr("0x" SubStr(m, 3)), i := j + StrLen(m)
    return e . SubStr(s, i)
}
+ DD