Forum Moderators: open
Parse the name/value pair for the keyword values.
Good luck!
I've pasted it in this thread:
[webmasterworld.com...]
Cheers
SN
Function GetWords(i as String) as String
dim query_ids()
query_ids = Array("q=", "query=", "p=", "qry=", "string=", "searchfor=", "qkw=", "url=", "va=", "vp=", "key=", "queryterm=", "keywords=", "s=")
o = ""
c = 0
Do While c < UBound(query_ids)
s = query_ids(c)
If InStr(1, i, s) > 0 Then
we = (InStr((InStr(1, i, s) + Len(s) - 1), i, "&") - 1)
If we < (InStr(1, i, s) + Len(s) - 1) Then we = Len(i)
o = Right(Left(i, we), Len(Left(i, we)) - (InStr(1, i, s) + Len(s) - 1))
Exit Do
End If
c = c + 1
Loop
GetWords = o
End Function
If anyone has any search phrase identifiers to add to that query_ids array please let me know! :) I went through 12 months worth of stats to find all them
As a side note, I experimented with testing all referals for "=" and taking the string after that, and testing that for length and whether it contains numbers (which are usually useless stats for me) but that didnt work too good. I got about 9000 phrases from that method as opposed to 11000 for the method demonstrated above. Whats more, the 11000 are all pure, where-as quite a few of the 9000 were bogus or contained bogus elements.
I think what would be rarely good for porting to another analysis tool is to return the data as an array of words, or even better an object with the array of strings and the search engine location (Country id or .com) and the page number.
On Error GoTo ErrH
o = i
If InStr(1, i, "%") > 0 Then
If Left(i, 1) = "%" Then
a = Split(Right(i, Len(i) - 1) & "%", "%")
c = 0
o = ""
Else
a = Split(i & "%", "%")
c = 1
o = a(0)
End If
u = UBound(a)
While c < u
t = "&H" & Left(a(c), 2)
l = CLng(t)
o = o & Chr(l) & Right(a(c), Len(a(c)) - 2)
c = c + 1
Wend
End If
UnEncodeURL = Replace(Replace(o, Chr(34), ""), "+", " ")
Exit Function
ErrH:
UnEncodeURL = " "
End Function
Function GetWords(i As String) As String
Dim s As String
Dim o As String
Dim t As String
Dim c As Integer
Dim we As Integer
Dim a
Dim m
Dim query_ids()
Const min_word_len = 3
Const max_word_len = 32
m = min_word_len
x = max_word_len
query_ids = Array("q=", "query=", "p=", "qry=", "string=", "searchfor=", "qkw=", "url=", "va=", "vp=", "key=", "queryterm=", "keywords=", "s=")
GetWords = ""
c = 0
Do While c < UBound(query_ids)
s = query_ids(c)
If InStr(1, i, s) > 0 Then
we = (InStr((InStr(1, i, s) + Len(s) - 1), i, "&") - 1)
If we < (InStr(1, i, s) + Len(s) - 1) Then we = Len(i)
o = Right(Left(i, we), Len(Left(i, we)) - (InStr(1, i, s) + Len(s) - 1))
Exit Do
End If
c = c + 1
Loop
'o = ""
'If InStr(1, i, "=") Then
' a = Split(i, "=")
' c = 1
' While c < UBound(a)
' If InStr(1, a(c), "&") > 0 Then
' t = Left(a(c), InStr(1, a(c), "&") - 1)
' If Len(t) >= m Then o = o & t & " "
' Else
' If Len(a(c)) >= m And Len(a(c)) <= x Then
' o = o & a(c) & " "
' End If
' End If
' c = c + 1
' Wend
'End If
o = UnEncodeURL(o)
If Not o = "" And InStr(1, o, " ") > 0 Then
o = SortWords(o)
a = Split(o, " ")
o = ""
c = 0
While c < UBound(a)
If (Len(a(c)) >= m And Len(a(c)) <= x) And NoNumbers(a(c)) = True Then
o = o & a(c) & " "
End If
c = c + 1
Wend
ElseIf Len(o) < m Or Len(o) > x Or NoNumbers(o) = False Then
o = ""
End If
GetWords = LCase(o)
End Function
Function NoNumbers(ByVal i As String) As Boolean
Dim s
s = "0123456789"
c = 0
While c < Len(s)
c = c + 1
If InStr(1, i, Mid(s, c, 1)) > 0 Then
NoNumbers = False
Exit Function
End If
Wend
NoNumbers = True
End Function
Function SortWords(i As String) As String
Dim a
Dim rs_t As Recordset
a = Split(i & " ", " ")
Set rs_t = New Recordset
rs_t.Fields.Append "w", adVarChar, 255
rs_t.Open
c = 0
While c < UBound(a)
rs_t.AddNew
rs_t("w") = a(c)
c = c + 1
Wend
rs_t.Sort = "[w] ASC"
rs_t.MoveFirst
While Not rs_t.EOF
o = o & rs_t("w") & " "
rs_t.MoveNext
Wend
SortWords = o
End Function
Sort words sorts the words in each phrase alphabetically. Probably worth mentioning I am using this particular script in an access database, so you may need to change some stuff like the Recordset object creation for use in an ASP page.