HTML Parser

By biase on May 22, 2020

  • HTML Parser -
    you can scrap webs using this alias ..
  • Requirement: Internet Explorer 9 and above

Opening/parsing data into the NAME
$html(,<URL|FILE|HTMLString>)
for URL : noop $html(NAME,https://forums.mirc.com/ubbthreads.php/forums/5/1/scripts-popups)
for FILE : noop $html(NAME,html_content_source.html)
for TEXT: noop $html(NAME,'Scripts & Popups - mIRC Discussion Forums')

  • Note: parsing html string must enclose it using ' or "

$html(NAME).close
Closing the NAME: noop

$html(,,N)
Returns the value of the properties
Properties: innerHTML, innerText, src, href, content, charset etc..
and many more attribute from html tag.

usage example:
$html(Name,title) - return the title of the NAME
$html(Name,script,N) - return length
Example: $html(Name,a,3).href - return the link name in third a in the NAME

-- Simple Example
noop $html(mirc,https://forums.mirc.com/ubbthreads.php/forums/5/1/scripts-popups)
echo -s $html(mirc,title) ; return Scripts & Popups - mIRC Discussion Forums
echo -s $html(mirc,a,0) ; return total a tags
echo -s $html(mirc,a,2) ; return Home
echo -s $html(mirc,a,2).href ; return http://www.mirc.com/index.html
noop $html(mirc).close

  • Note : since i use querySelectorAll, you also can select using className or li.classname > a
    same like jQuery.
/*
Name   : HTML Parser
Version: 1.1.2.5
Created: 1589357273
Author : Lite @ SkyChatz, KampungChat & mIRCScripts

--- H E L P ---
Opening/parsing data into the NAME
$html(<NAME>,<URL|FILE|HTMLString>)
for URL : noop $html(NAME,https://forums.mirc.com/ubbthreads.php/forums/5/1/scripts-popups)
for FILE: noop $html(NAME,html_content_source.html)
for TEXT: noop $html(NAME,'<title>Scripts &amp; Popups - mIRC Discussion Forums</title>')
- Note: parsing html string must enclose it using ' or "

$html(NAME).close
Closing the NAME: noop 

$html(<NAME>,<HTML TAG>,N)
Returns the value of the properties
Properties: innerHTML, innerText, src, href, content, charset etc..
and many more attribute from html tag.

usage example:
$html(Name,title) - return the title of the NAME
$html(Name,script,N) - return length
Example: $html(Name,a,3).href - return the link name in third a in the NAME

-- Simple Example
noop $html(mirc,https://forums.mirc.com/ubbthreads.php/forums/5/1/scripts-popups)
echo -s $html(mirc,title)  ; return Scripts & Popups - mIRC Discussion Forums
echo -s $html(mirc,a,0)   ; return total a tags
echo -s $html(mirc,a,2)  ; return Home
echo -s $html(mirc,a,2).href ; return http://www.mirc.com/index.html
noop $html(mirc).close
*/

alias html {
  var %js jshf, %result $!null($com(jshf,eval,3,bstr,%script)) $!com(jshf).result, %script typeof( $+ $$1 $+ )
  if (!$com(jshf)) { .comopen jshf msscriptcontrol.scriptcontrol | noop $com(jshf,language,5,bstr,jscript) }
  if (!$2) {
    if ($prop == close) return $null($com(jshf,eval,3,bstr,$$1 = undefined))
    echo $color(info) -s * $!html() need atleast 2 argument. 
    return
  }

  var %jscript $&
    var $1 = new ActiveXObject("htmlfile"), xh = new ActiveXObject("MSXML2.XMLHTTP.6.0"), fso = new ActiveXObject("Scripting.FileSystemObject"); $&
    $1 $+ .write('<meta http-equiv="x-ua-compatible" content="IE=9" />'); $&
    function loadurl(url){xh.open('GET',url,false);xh.send(); $+ $1 $+ .write(xh.responseText); $+ $1 $+ .close();} $crlf $&
    function loadhtml(string){ $+ $1 $+ .write(string); $+ $1 $+ .close();} $crlf $&
    function fileread(file){var fso = new ActiveXObject("Scripting.FileSystemObject");return (fso.FileExists(file) ? fso.OpenTextFile(file,1).ReadAll():'');}; $crlf $&

  if ($(,%result) == undefined) noop $com(%js,addcode,1,bstr,%jscript)
  if ($regex($2,/((?:ht|f)tps?:\/\/[a-z0-9-_.?&=%\\/]+)/i)) %script = loadurl( $+ $qt($regml(1)) $+ )
  elseif ($regex($2,/(<.+?>)/)) %script = loadhtml( $+ $2 $+ )
  elseif ($isfile($2)) %script = loadhtml(fileread( $+ $qt($2) $+ ))
  else {
    var %ifprop $iif($istok(href src,$prop,32),.getAttribute(" $+ $prop $+ "),. $+ $prop), $&
      %prop $iif($prop,%ifprop,$iif(meta* iswm $2,.content,.innerText)), $&
      %script $1 $+ .querySelectorAll(' $+ $2 $+ ') $+ $iif($3 === 0,.length,[ $+ $iif($3 > 0,$calc($3 -1),0) $+ $(]) $+ %prop $+ )
  }
  return $(,%result)
}

Comments

Sign in to comment.
Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.