mIRC Home    About    Download    Register    News    Help

Print Thread
#226948 20/10/10 06:37 AM
Joined: Aug 2010
Posts: 69
N
N3M3S1S Offline OP
Babel fish
OP Offline
Babel fish
N
Joined: Aug 2010
Posts: 69
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!!


"There is no theory of evolution, only a list of creatures Chuck Norris allows to live."
Joined: Jun 2007
Posts: 933
5
Hoopy frood
Offline
Hoopy frood
5
Joined: Jun 2007
Posts: 933
My guess: read the "Note:" and "Example:" in /help /sockread

Joined: Jan 2007
Posts: 1,156
D
Hoopy frood
Offline
Hoopy frood
D
Joined: Jan 2007
Posts: 1,156
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.

Joined: Oct 2010
Posts: 5
D
dvl Offline
Nutrimatic drinks dispenser
Offline
Nutrimatic drinks dispenser
D
Joined: Oct 2010
Posts: 5


Link Copied to Clipboard