[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Keywords from Internet Explorere Address Bar .....

Posted on 2004-10-30
14
Medium Priority
?
214 Views
Last Modified: 2010-08-05
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
0
Comment
Question by:bkniazi
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 3
  • 2
  • +3
14 Comments
 
LVL 6

Expert Comment

by:Amritpal Singh
ID: 12450953
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
 
LVL 6

Expert Comment

by:Amritpal Singh
ID: 12450957
sorry ,
do while (pos1 <> - 1)
 pos2 = (Instr("./?=&),Mid(URL,Pos1))
 keyword = Mid(URL,pos1,pos2-pos1)
 pos1 = pos2 + 1
loop
0
 
LVL 14

Expert Comment

by:Shiju Sasidharan
ID: 12451018
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
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.

 
LVL 14

Expert Comment

by:Shiju Sasidharan
ID: 12451028
hi
>>specify a small link
means the url u want to extract

;-)
Shiju
0
 

Author Comment

by:bkniazi
ID: 12451113
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
 

Author Comment

by:bkniazi
ID: 12451122
Dear amrit_82,

try to use ur own code in vb6 plz.

thx
0
 
LVL 14

Expert Comment

by:Shiju Sasidharan
ID: 12451272
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
 
LVL 17

Expert Comment

by:zzzzzooc
ID: 12451925
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
 
LVL 14

Expert Comment

by:aelatik
ID: 12456607
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
 
LVL 14

Accepted Solution

by:
aelatik earned 400 total points
ID: 12456621
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
 

Author Comment

by:bkniazi
ID: 12460471
yes shijusn
0
 

Author Comment

by:bkniazi
ID: 12460542
check the Aelatik code.
0
 
LVL 1

Assisted Solution

by:AsifBangash
AsifBangash earned 400 total points
ID: 12460562
Hi Bkniazi,

I sugis u to use Aelatik code cause he is a lion of Visual Basic.
0
 

Author Comment

by:bkniazi
ID: 12460572
thx Aelatik and u AsifBangash.
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

656 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question