Dies ist eine alte Version des Dokuments!


Highlighting

Dieses Script erlaubt es ohne Webbrowser in Google zu suchen.

Der Befehl /google SUCHBEGRIFF zeigt einem selber die Ergebnisse an und /pgoogle SUCHBEGRIFF zeigt dem Channel bzw. dem Query-Partner die Ergebnisse an.

#NewScriptBegin GoogleSearch
 
Dim SExpr
Dim DataBuff
Dim MyConn
Dim PageNum
dim CurrP
dim PubS
 
Sub Load()
  MakeShortcut "", "google", "/call GoogleSearch.FindText 0 1 :$>0", 2
  MakeShortcut "", "pgoogle", "/call GoogleSearch.FindText 1 1 :$>0", 2
  PageNum=5
End Sub
 
Sub FindText(PubSearch, Page, Expr)
  Print "~ Verbinden...", 0, valcClientMsg
  CurrP = Page
  SExpr = Replace(Expr," ", "+")
  PubS=PubSearch
  if PubS = 1 Then
    PageNum=3
    Send "Googlesuche nach " + Expr + ":", FrontFrameID 
  else
    PageNum=5
  End if
  MyConn=dccconnect("www.google.de",80,"","",0,1)
End Sub
 
Sub Serv_Connected(ConnID)
  if ConnID = MyConn Then
    SendData "GET /search?q=" & SExpr & "&num=" & PageNum & "&start=" & (CurrP-1)*PageNum & " HTTP/1.0", ConnID
    SendData "User-Agent: Mozilla/4.0 (compatible; Nettalk " + Version + "; SearchScript)", ConnID
    SendData "Connection: Close"+chr(13)+chr(10), ConnID
    DataBuff=""
    Print "~ Verbunden, warte auf Daten...", 0, valcClientMsg
  End if
End Sub
 
Sub RecvDCCMsg(Text, Nick, FrameID, ConnID)
  if ConnID = MyConn Then
    Data=DataBuff & Text
    i2=0
    Do
      i=instr(i2+1,Data,"<a class=l")
      if i > 0 Then
        i2=instr(i+1,Data,"</tr>")
        if i2=0 Then
          DataBuff = Mid(Data,i)
          i=0
        Else
          i3=instr(i+20,Data,Chr(34))
          i5=instr(i3+1,Data,"<td class=j>")
          if i5 > 0 Then
            i4=instr(i5, Data, "<span")
            if i4=0 Then i4=instr(i5, Data, "</td>")
            if PubS = 1 Then
              Send RemTags(Mid(Data,i5,i4-i5))+" ("+Mid(Data,i+17,i3-(i+17))+")", FrontFrameID
            else
              Print  "- " + RemTags(Mid(Data,i5,i4-i5))+ " (", 0, valcText
              Print Mid(Data,i+17,i3-(i+17)), 0, valcLink, 1
              Print  ") ", 0, valcText, 1
              Print  " ", 0, valcText
            end if
          End if
          DataBuff=""
        End if
      End if
    Loop until i=0
    if Right(Data,7)="</html>" Then
      CloseConn ConnID
      DataBuff=""
      Print "~ Ende der Liste (", 0, valcClientMsg
      Print "Weitere...", 0, valcLink, 1, "SearchNextPage"
      Print ")", 0, valcClientMsg, 1
    End if
  End if
End Sub
 
Sub ScriptLinkClicked(Text, Trigger, Button)
  if Trigger="SearchNextPage" Then
    FindText PubS, CurrP+1, SExpr
  End if
End Sub
 
Function RemTags(Text)
  OutText=""
  i2=0
  Do
    i=instr(i2+1, Text, "<")
    if i = 0 Then
      OutText = OutText + Mid(Text, i2+1)
    else
      if i-i2 > 1 Then OutText = OutText + Mid(Text, i2+1, i-i2-1)
      i2=instr(i, Text, ">")
    End if
  Loop until i=0 or i2=0
  RemTags = Trim(OutText)
End Function

Eigene Werkzeuge