Jump to content

Archived

This topic is now archived and is closed to further replies.

chain

3 Lined Google Script

Recommended Posts

  • Administrators
I was challenged to make this by mememe33 who said that he could make a simple google script in 5 lines. I took advantage of that and made it in 3. Yes it is extremely messy but I havent posted a script like this on here because I just havent been ready to post scripts on here. There is a $nohtml alias added to the script to make it work more effectivly. Anyway,

 

Syntax: !google

Features: Multiple Sockets, Google Feeling Lucky Output

 

 

>on $*:TEXT:/^[@!.]google.*$/Si:#:{ if (!$2) { /notice $nick $c1(You have not specified anything to search. Please try again.) | halt } inc %gid | /set $+(%,google,%gid) $iif($left($1,1) == @,msg $chan,.notice $nick) | /set $+(%,gsearch,%gid) $2- | /sockopen $+(google.,%gid) www.google.com 80 }on *:SOCKOPEN:google.*:{ /sockwrite -n $sockname GET $+(/search?hl=en&q=,$replace($($+(%,gsearch,%gid),2),$chr(32),+),&btnI=) HTTP/1.1 | /sockwrite -n $sockname Host: www.google.com $+ $crlf $+ $crlf }on *:SOCKREAD:google.*:{ var %read | sockread %read | if (Location:* iswm %read) { $($+(%,google,%gid),2) $+([,Google Result,]:) $+(Top result for ",$($+(%,gsearch,%gid),2),", $+ :) $remove($nohtml(%read),Location: $+ $chr(32)) | /unset $+(%,gsearch,$gettok($sockname,2,46)) | /unset $+(%,google,$gettok($sockname,2,46)) | /sockclose $sockname } | if (*did not match any documents* iswm %read) {  $($+(%,google,%gid),2) [Google Result]: $+(Result for ",$($+(%,gsearch,%gid),2),", $+ :) Did not return any search results. Please try again. | /unset $+(%,*,$gettok($sockname,2,46)) | /unset $+(%,*,$gettok($sockname,2,46)) } }alias nohtml { var %x, %i = $regsub($1-,/(^[^|]*>|]*$)/g,$null,%x), %x = $remove(%x, ) | return %x }

 

My friend Jaytea has made an alias for it to work in 2 lines without the $nohtml alias.

 

alias google_ sockopen g google.com 80 | .timer 1 2 sockwrite g $+(GET /search?q=,$regsubex($1-,/ /g,+) HTTP/1.0,$lf,$lf)

on *:sockread:g:$event &a | echo -a $token($bvar(&a,$$iif($bfind(&a,1,s=g>

 

Annd... Jaytea's one lined alias *Edited to be faster and shorter and less cluttered

 

Link to comment
Share on other sites



×
×
  • Create New...