[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 225
  • Last Modified:

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.
0
AsifBangash
Asked:
AsifBangash
  • 6
  • 5
  • 4
2 Solutions
 
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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
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
 
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

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

  • 6
  • 5
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now