Gah, I feel like tardiness will cost me one.
Try this out. So far, it just returns results, with a link to each result:
'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