mIRC Home    About    Download    Register    News    Help

Print Thread
#226948 20/10/10 06:37 AM
N
N3M3S1S
N3M3S1S
N
Here is my code.

Code:
on *:TEXT:!google*:#: {
  if ($2- != $null) {
    set %google.num 0
    set %google.channel $chan
    set %google.search $replace($2-,$chr(32),$chr(43))
    sockclose google
    sockopen google www.google.com 80 
  }
}
on *:sockopen:google: {
  sockwrite -n $sockname GET $+(/search?sourceid=navclient&hl=en&ie=UTF-8&rls=GGLD,GGLD:2004-04,GGLD:en&q=,%google.search) HTTP/1.1
  sockwrite -n $sockname Host: www.google.com
  sockwrite -n $sockname Conenction: Keep-Alive
  sockwrite -n $sockname $crlf
}
on *:sockread:google: {
  sockread %google.tmp
  if ($regex(%google.tmp,/<h2 class=.*><a href="(.*)" class=l>.*<b>/)) { 
    boris.cmd privmsg %google.channel 12,1G4o8o12g3l4e15 Search Result:3 $regml(1)
    inc %google.num
  }
  if (%google.num == 3) {
    sockclose google
    unset %google* 
  }
}


It works but only returns 1 result frown I've messed with this thing for HOURS and all I get is one result. HAAALP!!

#226949 20/10/10 06:52 AM
5
5618
5618
5
My guess: read the "Note:" and "Example:" in /help /sockread

#226964 20/10/10 03:02 PM
Joined: Jan 2007
Posts: 1,155
D
Hoopy frood
Offline
Hoopy frood
D
Joined: Jan 2007
Posts: 1,155
Just from a quick glance:

Code:
  if ($regex(%google.tmp,/<h2 class=.*><a href="(.*)" class=l>.*<b>/)) { 
    boris.cmd privmsg %google.channel 12,1G4o8o12g3l4e15 Search Result:3 $regml(1)
    inc %google.num
  }


It appears that this regex check will tell you where the search results start. This only matches in this one place on the page, so since you are only echoing the line that matches the regex statement, it only returns the one line. Set a variable that tells you you are at the beginning of the search results. Then, if the variable is true, exho the lines and see what you will need to do to strip the url from them.

#226990 21/10/10 07:33 AM
D
dvl
dvl
D


Link Copied to Clipboard