Posted by: Ace
« on: March 15, 2009, 06:25:02 AM »Should we be posting gnome scripts that annoy the crap out of people sometimes? For the amount of people we could get, I go against it. You can send it via PM.
It was two topics about the same thing. This one you just requested it and you requested it in the other one too, which kind of makes it the same thing.Silly hale...
'gp
'0.1
'&Google Plugin:Vector:Searches google, and returns the results of the search
'*
'*
'*
'*
'*Fun
Const gpAcc = 20
Public xmlGet, arrFloodProtect
Sub gp_Event_Load()
Set xmlGet = CreateObject("Microsoft.XmlHttp")
End Sub
Sub gp_Event_UserTalk(Username, Flags, Message, Ping)
GetDBEntry Username, a, f : If a < gpAcc Then Exit Sub
If Left(Message, Len(BotVars.Trigger) + 6) = BotVars.Trigger & "gfind " Then
getQuery = Right(Message, Len(Message) - (Len(BotVars.Trigger) + 6))
getQuery = Replace(getQuery, " ", "+")
Call retrieveResult(getQuery)
End If
End Sub
Sub retrieveResult(getQuery)
xmlGet.Open "GET", "http://www.google.com/search?hl=en&q="&getQuery&"&btnG=Google+Search&aq=f&oq=", False
xmlGet.Send ""
content = xmlGet.ResponseText
getNumResults = Split(Split(content, "Results ")(1), " </div>")(0)
getNumResults = strip(getNumResults)
AddQ getNumResults
parseResults = Split(Split(content, "Search Results")(1), "http://")
idx = -1
For i=0 to Ubound(parseResults)
getLink = Split(parseResults(i), """")(0)
If Len(getLink) > 25 Then
getLink = "http://" & Split(getLink, "/")(0) & " [link truncated]"
Else
getLink = "http://" & getLink
End If
If InStr(parseResults(i), "this.href,'','','res'") Then
getText = Split(parseResults(i), "this.href,'','','res'")(1)
getText = Split(getText, "</a>")(1)
getText = Replace(getText, "<a href""", "")
getText = Strip(getText)
getText = Trim(Left(getText, Len(getText) - 9))
If Len(getText) > 140 Then getText = Left(getText, 140) & " ..."
getElem = getText & " Link: " & getLink
idx = idx + 1
ReDim Preserve arrFloodProtection(idx)
arrFloodProtection(idx) = getElem
End If
Next
For i=0 to Ubound(arrFloodProtection)
AddQ arrFloodProtection(i)
Next
End Sub
Function strip(parseOutChars)
tagF = Array(""", "<b>", "</b>")
tagR = Array("""", "", "")
getTagCount = Ubound(Split(parseOutChars, "<"))
For i=1 to getTagCount
getTag = Split(Split(parseOutChars, "<")(i), ">")(0)
parseOutChars = Replace(parseOutChars, getTag, vbNullString, 1, 1)
Next
parseOutChars = Replace(parseOutChars, "<>", vbNullString)
i = 0
For each tag in tagF
parseOutChars = Replace(parseOutChars, tag, tagR(i))
i = i + 1
Next
strip = parseOutChars
End Function
'gg
'1.0
'&GoogleGnome Plugin By EKLIPz
'&
'&
'&My Scipting project.
Sub gg_Event_Load()
AddChat vbGreen, "EKLIPz' GoogleGnome v.01 plugin loaded."
End Sub
Sub blank_Event_Close()
AddChat vbCyan, "GoogleGnome closing."
End Sub