Advertisement
westor

URL Grabber for Dune2K v1.0

May 18th, 2020
4,014
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. alias -l urlencode { return $regsubex($1-,/([^a-z0-9])/ig,% $+ $base($asc(\t),10,16,2)) }
  2. alias -l isurl { noop $regex(isurl,$1-,m@^((?:(?:https?)://(?:www\.)?|www\.)((?:(?:[-\w]+\.)+)[-\w]+)(?::\d+)?(?:/(?:[-a-zA-Z;/\d#:_?=&@,()+~.%]*))?)$@ig) | return $iif($regml(isurl,0),1,0) }
  3.  
  4. ON *:TEXT:*:#: {
  5.   tokenize 32 $strip($1-)
  6.  
  7.   var %t = $numtok($1-,32)
  8.   var %i = 1
  9.  
  10.   while (%i <= %t) {
  11.     var %w = $gettok($1-,%i,32)
  12.  
  13.     if (%w) && ($isurl(%w)) { get_title $chan %w }
  14.  
  15.     inc %i
  16.   }
  17. }
  18.  
  19. alias get_title {
  20.   if (!$1) && (!$2) { return }
  21.  
  22.   var %dom = $gettok($2-,2,47)
  23.   var %url = $gettok($2-,3-,47)
  24.  
  25.   :start
  26.   var %s = URL_SEARCH_ $+ $ticks $+ $rand(1,100000)
  27.  
  28.   if ($sock(%s)) { goto start }
  29.  
  30.   if (*https://* iswm $1-) { sockopen -e %s %dom 443 }
  31.   else { sockopen %s %dom 80 }
  32.  
  33.   sockmark %s $1 %url
  34.  
  35.   socklist
  36. }
  37.  
  38. ON *:SOCKOPEN:URL_SEARCH_*: {
  39.   if ($sockerr) { return }
  40.  
  41.   sockwrite -nt $sockname GET / $+ $gettok($sock($sockname).mark,2-,32) HTTP/1.1
  42.   sockwrite -nt $sockname User-Agent: Mozilla/5.0 (Windows NT 10.0 $+ $chr(59) Win64 $+ $chr(59) x64 $+ $chr(59) rv:61.0) Gecko/20100101 Firefox/61.0
  43.   sockwrite -nt $sockname Host: $sock($sockname).addr
  44.   sockwrite -nt $sockname Connection: Close
  45.   sockwrite -nt $sockname $crlf
  46. }
  47.  
  48. ON *:SOCKREAD:URL_SEARCH_*: {
  49.   if ($sockerr) { return }
  50.  
  51.   var %r
  52.   sockread %r
  53.  
  54.   ; echo 2 -s DEBUG: %r
  55.  
  56.   if ($regex(%r,/\<title\>(.*)\<\/title\>/i)) {
  57.     var %title = $regml(1)
  58.     var %c = $gettok($sock($sockname).mark,1,32)
  59.  
  60.     if (%title) && ($me ison %c) { msg %c Title: %title }
  61.  
  62.     sockclose $sockname
  63.   }
  64. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement