Keywords from Internet Explorere Address Bar .....

Hi all,

I've a small problem. I want to get keywords fro URL e.g:

(http://loginnet.passport.com/login.srf?id=2&svc=mail&cbid=24325&msppjph=1&tw=0&fs=1&fsa=1&fsat=1296000&lc=1033&_lang=EN)

In this URL keywords are:

1. loginnet
2. passport
3. 2 (after (=) value)
4. mail (after (=) value)
5 24325 (after (=) value)
6. 1 (after (=) value)
7. 0 (after (=) value)
8. 1 (after (=) value)
9. 1 (after (=) value)
10. 1296000 (after (=) value)
11. 1033 (after (=) value)
12. EN (after (=) value)

Means kewords split when got (".", "/", "?", "=", "&").

Help me

Waiting for ur positive response.

Thx
bkniaziAsked:
Who is Participating?
 
aelatikConnect With a Mentor Commented:
A little modification...

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, ".")
                        If LCase(TMP1(0)) <> "www" Then KEYWORDS = KEYWORDS & TMP1(0) & vbCrLf
                        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://loginnet.passport.com/login.srf?id=2&svc=mail&cbid=24325&msppjph=1&tw=0&fs=1&fsa=1&fsat=1296000&lc=1033&_lang=EN)"), vbInformation, "Keywords found"
End Sub
0
 
Amritpal SinghCommented:
hi bkniazi,

u can use Instr function for this

something like

pos1 = 0
pos2 = 0

do while (pos1 <> - 1)
 pos1 = (Instr("./?=&",URL))
 pos2 = (Instr("./?=&),Mid(URL,Pos1))
 keyword = Mid(URL,pos1,pos2-pos1)
loop

where URL is the string containing ur URL
   
0
 
Amritpal SinghCommented:
sorry ,
do while (pos1 <> - 1)
 pos2 = (Instr("./?=&),Mid(URL,Pos1))
 keyword = Mid(URL,pos1,pos2-pos1)
 pos1 = pos2 + 1
loop
0
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
Shiju SasidharanAssoc Project ManagerCommented:
Hi
plz be specific
u need to extract all words from that link?
or only those words which lie between the characters u specified?
it would be better u specify a small link and give the results u expect to be obtained after extraction
;-)
Shiju
0
 
Shiju SasidharanAssoc Project ManagerCommented:
hi
>>specify a small link
means the url u want to extract

;-)
Shiju
0
 
bkniaziAuthor Commented:
Dear Shijusn,

for example: ("http://www.yahoo.com/mess/abc?xyz=123&asd=432")

i want to extract keywords from it like ('yahoo' and 'mess'  i don't need of 'http://' , don't need of 'www', don't need of '?', don't need of '='and don't need of '&'.
after '/' i want to get data after (=) sign to (&) sign. Simply between '=' and '&'.

from this URL keywords are:
Yahoo
Mess
123
432

but remember that will be dynimcally.

thx
waiting .................................................
0
 
bkniaziAuthor Commented:
Dear amrit_82,

try to use ur own code in vb6 plz.

thx
0
 
Shiju SasidharanAssoc Project ManagerCommented:
hi bkniazi
few more questions to make me more clear

source string will always be url , i.e starting with http://www.  ?
if it is line http://www.first.second.third.com/?value=234&value2=test
u need ....

first
second
third
234
test
     
if i am wrong pls correct it.

u need extracted results in the same order they occur in the url ? or in any order ?
;-)
Shiju



0
 
zzzzzoocCommented:
Form1:
----------------------------
Option Explicit
Private Sub Form_Load()
    Dim colQuery As Collection, clsVars As Class1, varTemp As Variant
    'Parse URL for site address
    If ParseAddress("http://loginnet.passport.com/login.srf?id=2&svc=mail&cbid=24325&msppjph=1&tw=0&fs=1&fsa=1&fsat=1296000&lc=1033&_lang=EN", colQuery) = True Then
        For Each varTemp In colQuery
            Debug.Print varTemp
        Next varTemp
    End If
    'Parse URL for variables/values such as "X=1"
    If ParseQuery("http://loginnet.passport.com/login.srf?id=2&svc=mail&cbid=24325&msppjph=1&tw=0&fs=1&fsa=1&fsat=1296000&lc=1033&_lang=EN", colQuery) = True Then
        For Each clsVars In colQuery
            Debug.Print clsVars.var, clsVars.val
        Next clsVars
    End If
End Sub
Private Function ParseAddress(ByVal strURL As String, ByRef colQuery As Collection) As Boolean
    Dim strSplit1() As String, intLoop1 As Integer
    Dim strSplit2() As String, intLoop2 As Integer
    Set colQuery = New Collection
    strSplit1() = Split(LCase(strURL), "/")
    For intLoop1 = 0 To UBound(strSplit1)
        If InStr(1, strSplit1(intLoop1), ".") > 0 Then
            strSplit2() = Split(strSplit1(intLoop1), ".")
            For intLoop2 = 0 To UBound(strSplit2)
                If IsBlacklisted(strSplit2(intLoop2)) = False Then
                    Call colQuery.Add(strSplit2(intLoop2))
                End If
            Next intLoop2
        Else
            If IsBlacklisted(strSplit1(intLoop1)) = False Then
                Call colQuery.Add(strSplit1(intLoop1))
            End If
        End If
    Next intLoop1
    ParseAddress = True
End Function
Private Function ParseQuery(ByVal strURL As String, ByRef colQuery As Collection) As Boolean
    Dim strSplit1() As String, intLoop1 As Integer
    Dim strSplit2() As String
    Dim clsVars As Class1
    strSplit1() = Split(LCase(strURL), "?")
    'url cannot have more than 1 "?"!!!
    If UBound(strSplit1) = 1 Then
        Set colQuery = New Collection
        strSplit1 = Split(strSplit1(1), "&")
        For intLoop1 = 0 To UBound(strSplit1)
            strSplit2() = Split(strSplit1(intLoop1), "=")
            'var=val cannot have more than one "="!!
            If UBound(strSplit2) = 1 Then
                Set clsVars = New Class1
                clsVars.var = strSplit2(0)
                clsVars.val = strSplit2(1)
                Call colQuery.Add(clsVars, strSplit2(0))
            End If
        Next intLoop1
        ParseQuery = True
    End If
End Function
Private Function IsBlacklisted(ByVal strText As String) As Boolean
    Select Case strText
        Case "www", "http:", "ftp:", ""
            IsBlacklisted = True
    End Select
    If InStr(1, strText, "?") > 0 Then
        IsBlacklisted = True
    End If
End Function


Class1:
-----------------------
Public var As String
Public val As String
0
 
aelatikCommented:
Here you go...

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=2&fs=1&cbid=24325"), vbInformation, "Keywords found"
End Sub
0
 
bkniaziAuthor Commented:
yes shijusn
0
 
bkniaziAuthor Commented:
check the Aelatik code.
0
 
AsifBangashConnect With a Mentor Commented:
Hi Bkniazi,

I sugis u to use Aelatik code cause he is a lion of Visual Basic.
0
 
bkniaziAuthor Commented:
thx Aelatik and u AsifBangash.
0
All Courses

From novice to tech pro — start learning today.