BSolveIT
02-06-2006, 09:33 PM
Hello all!
I've been hard at work writing little bits of code and I thought I would share a handy function I wrote to extract keyword data from Yahoo Search Marketing. It retrieves up to 100 related keyword terms, plus the number of times search on per day in the previous month.
I've configured the URL on this function to get UK based results, but if you want data for different locations, the URL accepts the same parameters as the Yahoo Search API.
e.g.
mkt=us
lang=en_us
I hope some of you will find it useful:
<%
Function GetKeywords(Term)
URL = "http://inventory.overture.com/d/searchinventory/suggestion/?mkt=uk&lang=en_gb&term=" & server.URLEncode(Term)
Set objXMLHTTP = Server.CreateObject("Microsoft.XMLHTTP")
objXMLHTTP.Open "GET", URL, False
objXMLHTTP.Send
html = objXMLHTTP.responseText
html = lcase(html)
Length = Len(html)
TheStart = InStr(1, html, "<table border=0 cellpadding=1 cellspacing=0 bgcolor=#ffffff width=270>")
IF TheStart > 0 THEN
Keywords = mid(html,TheStart,Length - TheStart)
TheStart = InStr(1, Keywords, "<tr bgcolor=#333333>")
Total = Split(keywords,"<tr")
TotalSize = Ubound(Total) - 2
Dim KeyArray
ReDim KeyArray (TotalSize, 2)
CountStart = InStr(1, Keywords, "> ") + 7
CountEnd = InStr(CountStart,Keywords, "</td>")
Keycount = mid(keywords, CountStart, CountEnd - CountStart)
KeyArray(0, 0) = Keycount
Keywords = replace(keywords, "e8e8e8> ", "#000000>")
KeyStart = InStr(CountEnd, Keywords, "#000000>") + 8
KeyEnd = InStr(KeyStart, Keywords, "</a>")
Keyphrase = Mid(Keywords,KeyStart, KeyEnd - KeyStart)
KeyArray(0, 1) = Keyphrase
FOR x = 1 TO TotalSize - 1
CountStart = InStr(KeyEnd, Keywords, "> ") + 7
CountEnd = InStr(CountStart,Keywords, "</td>")
Keycount = mid(keywords, CountStart, CountEnd - CountStart)
KeyArray(x, 0) = Keycount
KeyStart = InStr(CountEnd, Keywords, "color=#000000>") + 14
KeyEnd = InStr(KeyStart, Keywords, "</a>")
Keyphrase = Mid(Keywords,KeyStart, KeyEnd - KeyStart)
KeyArray(x, 1) = Keyphrase
NEXT
GetKeywords = KeyArray
exit function
ELSE
GetKeywords = False
END IF
End Function
%>
You can see it in action on our site if you click to use the free meta check from our home page.
Comments and suggestions would be most welcome!
8-|
I've been hard at work writing little bits of code and I thought I would share a handy function I wrote to extract keyword data from Yahoo Search Marketing. It retrieves up to 100 related keyword terms, plus the number of times search on per day in the previous month.
I've configured the URL on this function to get UK based results, but if you want data for different locations, the URL accepts the same parameters as the Yahoo Search API.
e.g.
mkt=us
lang=en_us
I hope some of you will find it useful:
<%
Function GetKeywords(Term)
URL = "http://inventory.overture.com/d/searchinventory/suggestion/?mkt=uk&lang=en_gb&term=" & server.URLEncode(Term)
Set objXMLHTTP = Server.CreateObject("Microsoft.XMLHTTP")
objXMLHTTP.Open "GET", URL, False
objXMLHTTP.Send
html = objXMLHTTP.responseText
html = lcase(html)
Length = Len(html)
TheStart = InStr(1, html, "<table border=0 cellpadding=1 cellspacing=0 bgcolor=#ffffff width=270>")
IF TheStart > 0 THEN
Keywords = mid(html,TheStart,Length - TheStart)
TheStart = InStr(1, Keywords, "<tr bgcolor=#333333>")
Total = Split(keywords,"<tr")
TotalSize = Ubound(Total) - 2
Dim KeyArray
ReDim KeyArray (TotalSize, 2)
CountStart = InStr(1, Keywords, "> ") + 7
CountEnd = InStr(CountStart,Keywords, "</td>")
Keycount = mid(keywords, CountStart, CountEnd - CountStart)
KeyArray(0, 0) = Keycount
Keywords = replace(keywords, "e8e8e8> ", "#000000>")
KeyStart = InStr(CountEnd, Keywords, "#000000>") + 8
KeyEnd = InStr(KeyStart, Keywords, "</a>")
Keyphrase = Mid(Keywords,KeyStart, KeyEnd - KeyStart)
KeyArray(0, 1) = Keyphrase
FOR x = 1 TO TotalSize - 1
CountStart = InStr(KeyEnd, Keywords, "> ") + 7
CountEnd = InStr(CountStart,Keywords, "</td>")
Keycount = mid(keywords, CountStart, CountEnd - CountStart)
KeyArray(x, 0) = Keycount
KeyStart = InStr(CountEnd, Keywords, "color=#000000>") + 14
KeyEnd = InStr(KeyStart, Keywords, "</a>")
Keyphrase = Mid(Keywords,KeyStart, KeyEnd - KeyStart)
KeyArray(x, 1) = Keyphrase
NEXT
GetKeywords = KeyArray
exit function
ELSE
GetKeywords = False
END IF
End Function
%>
You can see it in action on our site if you click to use the free meta check from our home page.
Comments and suggestions would be most welcome!
8-|