Keywords from Internet Explorere Address Bar .....

Hi,

I have a small problem. I want to get keywords from Internet Explorer Address Bar (means from URL).

e.g: http://www.geo.tv/chat/index.html 

In this Geo and Chat is the Keyword. If the URL is long then i'ud be get more keywords from URL. If URL is that:

http://www.experts-exchange.com/Programming/Programming_Languages/Visual_Basic/askQuestion.jsp

then get Keywords from it dynamically.

Any body help me.

Waiting for ur Positive Response.
LVL 1
AsifBangashAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

aelatikCommented:
Try this :

Private Function ExtractKeywords(URL As String) As String
    Dim KEYWORDS As String
    Dim TMP() As String
    Dim TMP1() As String
        TMP() = Split(URL, "/")
        For Each Item In TMP
            If Item <> "" Then
                If UCase(Left(Item, 4)) <> "HTTP" Then
                    If InStr(1, Item, ".") > 0 And Item <> TMP(UBound(TMP)) Then
                        TMP1() = Split(Item, ".")
                        Dim I As Long
                        If UBound(TMP1) > 1 Then
                            For I = 1 To UBound(TMP1) - 1
                                KEYWORDS = KEYWORDS & TMP1(I) & vbCrLf
                            Next
                        End If
                    Else
                        If InStr(1, Item, ".") = 0 Then
                            KEYWORDS = KEYWORDS & Item & vbCrLf
                        End If
                    End If
                End If
            End If
        Next
        ExtractKeywords = Left(KEYWORDS, Len(KEYWORDS) - 1)
End Function

Private Sub Form_Load()
    MsgBox ExtractKeywords("http://www.experts-exchange.com/Programming/Programming_Languages/Visual_Basic/askQuestion.jsp"), vbInformation, "Keywords found"
End Sub
0
Ryan ChongCommented:
Hi AsifBangash,

What's the "Keyword" you mean here? It's it value of the URL itself, or you mean it's the meta tag keyword in the page content that URL refered to ?
0
AsifBangashAuthor Commented:
Yes Ryancys
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

Ryan ChongCommented:
i'm mentioned for 2 possibilities here, so.. is:

a) It's it value of the URL itself, or

b) it's the meta tag keyword in the page content that URL refered to ?

8-)
0
AsifBangashAuthor Commented:
a) it's it value of the URL itself
0
aelatikCommented:
Did you try my post ?
0
Ryan ChongCommented:
Good... any logic behind on how to grab the keywords from URL? Did you try out aelatik's example on previous post?
0
AsifBangashAuthor Commented:
Aelatik ur code solved my problem but i m trying to split it "?" and "&" and "/" and "."

i solved it but if any sugesion to do this short plz

Thx Aelatik

0
aelatikCommented:
My code is already splitting "/" and "." ( you can see how its done there )
0
AsifBangashAuthor Commented:
but i m facing problem when check more "&" , "?" , "/" , "." , "="

help me
0
AsifBangashAuthor Commented:
Aelatik thx for code but i've a problem in this when i want to get another keywords e.g:
(lc=1033&id=2&tw=20&fs=1&cbid=24325)
ur code split it using "." and "/". i m also in need of split after "=" to "&" means
ic=1033&id=2&tw....
i want to get after = to & sign (1033 and another is 2) .

thx

waiting for ur positive response
0
Ryan ChongCommented:
to get the QueryString portion, you can try like:

Private Type QueryString
    Element As String
    Value As String
End Type
Dim myQueryString() As QueryString

Private Sub getQueryString(url As String)
    Dim tmp As String, tmpArr() As String, tmpArr2() As String, pos As Integer, i As Integer
    Dim cnt As Integer
    tmp = getFileName(url, "/")
    pos = InStr(1, tmp, "?", vbTextCompare)
    Erase myQueryString
    If pos > 0 Then
        tmp = Mid$(tmp, pos + 1)
        tmpArr = Split(tmp, "&", , vbTextCompare)
        For i = 0 To UBound(tmpArr)
            tmpArr2 = Split(tmpArr(i), "=", , vbTextCompare)
            If UBound(tmpArr2) = 1 Then
                ReDim Preserve myQueryString(cnt)
                myQueryString(cnt).Element = tmpArr2(0)
                myQueryString(cnt).Value = tmpArr2(1)
                cnt = cnt + 1
            End If
        Next i
    End If
End Sub

Public Function getFileName(filePath As String, Optional separator = "\") As String
    Dim tmp As String
    tmp = Mid$(filePath, InStrRev(filePath, separator) + 1)
    If tmp = filePath Then
        getFileName = ""
    Else
        getFileName = tmp
    End If
End Function

Private Sub Form_Load()
    Text1.Text = "http://www.mydomain.com/folder/mypage.asp?lc=1033&id=2&tw=20&fs=1&cbid=24325"
    getQueryString Text1.Text
   
    For i = 0 To UBound(myQueryString)
        Debug.Print myQueryString(i).Element & " value is " & myQueryString(i).Value
    Next i
End Sub

* Not fully tested, you need to add necessary error handler.

Hope this helps
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
aelatikCommented:
Just a little modification on my previous post. Just add this :

        If InStr(1, TMP(UBound(TMP)), "?") > 0 Then
            Dim TEMP As String
                TEMP = Split(TMP(UBound(TMP)), "?")(1)
                TMP = Split(TEMP, "&")
                For Each Item In TMP
                    KEYWORDS = KEYWORDS & Split(Item, "=")(1) & vbCrLf
                Next
        End If
0
aelatikCommented:
In full code it would be :


Private Function ExtractKeywords(URL As String) As String
    Dim KEYWORDS As String
    Dim TMP() As String
    Dim TMP1() As String
        TMP() = Split(URL, "/")
        For Each Item In TMP
            If Item <> "" Then
                If UCase(Left(Item, 4)) <> "HTTP" Then
                    If InStr(1, Item, ".") > 0 And Item <> TMP(UBound(TMP)) Then
                        TMP1() = Split(Item, ".")
                        Dim I As Long
                        If UBound(TMP1) > 1 Then
                            For I = 1 To UBound(TMP1) - 1
                                KEYWORDS = KEYWORDS & TMP1(I) & vbCrLf
                            Next
                        End If
                    Else
                        If InStr(1, Item, ".") = 0 Then
                            KEYWORDS = KEYWORDS & Item & vbCrLf
                        End If
                    End If
                End If
            End If
        Next
       
        If InStr(1, TMP(UBound(TMP)), "?") > 0 Then
            Dim TEMP As String
                TEMP = Split(TMP(UBound(TMP)), "?")(1)
                TMP = Split(TEMP, "&")
                For Each Item In TMP
                    KEYWORDS = KEYWORDS & Split(Item, "=")(1) & vbCrLf
                Next
        End If
       
        ExtractKeywords = Left(KEYWORDS, Len(KEYWORDS) - 1)
End Function

Private Sub Form_Load()
    MsgBox ExtractKeywords("http://www.experts-exchange.com/Programming/Programming_Languages/Visual_Basic/askQuestion.jsp?lc=1033&id=2&tw=20&fs=1&cbid=24325"), vbInformation, "Keywords found"
End Sub
0
AsifBangashAuthor Commented:
Dear Ryancys & Aelatik,

U both r great thx
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.