Read/Get website data

By ^WeSt on Oct 04, 2014

Requested for: http://forums.mirc.com/ubbthreads.php/topics/248339/Connect_to_a_page...#Post248339

Contact: http://westor.ucoz.com/contact


Usage: /sockget PAGE

Example: /sockget http://hawkee.com

alias sockget {
  if (!$1-) { echo -ag ERROR: Enter the URL Page correctly! | return }
  var %s = sockget_ $+ $rand(1,100000)
  if ($sock(%s)) { sockclose %s }
  var %site = $1-
  var %get_host = $chr(47) $+ $gettok(%site,3-,47)
  var %host = $gettok(%site,2,47)
  if ($right(%site,1) == $chr(47)) && ($right(%get_host,1) !== $chr(47)) { var %get_host = %get_host $+ $chr(47) }
  if (*https* iswm %site) { sockopen -e %s %host 443 }
  else { sockopen %s %host 80 }
  sockmark %s %get_host
}

ON *:SOCKOPEN:sockget_*: {
  if ($sockerr) { echo -ag ERROR: SOCKOPEN -> $sock($sockname).wserr -> $sock($sockname).wsmsg | return }
  sockwrite -nt $sockname GET $sock($sockname).mark HTTP/1.0
  sockwrite -n $sockname Host: $sock($sockname).addr
  sockwrite -n $sockname User-Agent: */*
  sockwrite -n $sockname Connection: Close
  sockwrite -nt $sockname $crlf
}

ON *:SOCKREAD:sockget_*: {
  if ($sockerr) { echo -ag ERROR: SOCKREAD -> $sock($sockname).wserr -> $sock($sockname).wsmsg | return }
  var %read
  sockread %read
  if ($sockbr) { echo -ag DATA: $left(%read,4096) }
}

ON *:SOCKCLOSE:sockget_*: { echo -ag CLOSED: $sock($sockname).addr SOCKET CONNNECTION! }    

Comments

Sign in to comment.
soulshined   -  May 28, 2016

Im new to mIRC but well versed in other programming languages. This is foriegn to me so I'm trying to understand. When using this with mIRC v7.45 I either get a CLOSED: SOCKET CONNECTION echo or nothing at all. Even when using www.example.com or www.google.com. My code is as such:
on *:JOIN:#channelname { /sockget http://google.com }

however my specific url might contain parameters like the username :
on *:JOIN:#channelname { /sockget http://google.com/?username=$nick&email=$nickemail }

The specific website URL is php which I'm posting those parameters to in order for it to echo a specific response (in php) which is why im guessing the URL isn't working, because im using URL parameters. So im not sure if i need to encode %20 or %26 or what in order to get this to work, regardless, even www.google.com isn't working with 7.45 any suggestions?

 Respond  
^WeSt   -  Nov 21, 2014
  • Code updated!

  • Fixed some errors on sockopen event
 Respond  
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.