Results 1 to 37 of 37

Thread: How to retrive a perticuler line of html code using Inet1.OpenURL

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Apr 2005
    Posts
    1,907

    Arrow How to retrive a perticuler line of html code using Inet1.OpenURL

    Hi all i got this code that prints the html code of a URL given. I wonder how i can filter out put to perticuler line of html code for example this line:

    "flash.swf?Live=717759220.txt"

    currently the code outputs the whole html but i only want the above line in html . Note the number before .exe is changing so i want that nunber and the rest of the line.I be happy if an expert show me a good soution for this problem.Thanks


    Code:
    Private Sub Command1_Click(Index As Integer)
    
    Select Case Index
        Case 0:
            If txtURL.Text <> "" Then
                RichTextBox1.Text = Inet1.OpenURL(txtURL.Text, icString)
            End If
        
        Case 1:
            End
    End Select
    End Sub

  2. #2
    PowerPoster lintz's Avatar
    Join Date
    Mar 2003
    Location
    The 19th Hole
    Posts
    2,697

    Re: How to retrive a perticuler line of html code using Inet1.OpenURL

    If you know the number sequence you're looking for use the Instr function.

    VB Code:
    1. Dim SearchText As String
    2. DIm URLSourceCode as String
    3.  
    4. URLSourceCode = Inet1.OpenURL(txtURL.Text, icString)
    5. SearchText = "flash.swf?Live=717759220.txt"
    6.  
    7. Instr(1, URLSourceCode, SearchText)

  3. #3
    Oi, fat-rag! bushmobile's Avatar
    Join Date
    Mar 2004
    Location
    on the poop deck
    Posts
    5,592

    Re: How to retrive a perticuler line of html code using Inet1.OpenURL

    You'll need something constant that you can position what your looking for in relation to.

    Will 'flash.swf?' or any other part always be the same?

    If flash.swf is consistant you could do something like:

    VB Code:
    1. Private Function GetLine(ByVal sText As String, ByVal sFind As String) As String
    2.     Dim lPos As Long, lEnd As String
    3.     lPos = InStr(1, sText, sFind, vbTextCompare)
    4.     If lPos Then
    5.         lEnd = InStr(lPos, sText, vbCrLf)
    6.         If lEnd Then
    7.             GetLine = Mid$(sText, lPos, lEnd - lPos - 1)
    8.         Else
    9.             GetLine = Mid$(sText, lPos)
    10.         End If
    11.     End If
    12. End Function
    13.  
    14. ' Call it like:
    15. sLine = GetLine(RichTextBox1.Text, "flash.swf")

  4. #4

    Thread Starter
    Frenzied Member
    Join Date
    Apr 2005
    Posts
    1,907

    Arrow Re: How to retrive a perticuler line of html code using Inet1.OpenURL

    Quote Originally Posted by lintz
    If you know the number sequence you're looking for use the Instr function.

    VB Code:
    1. Dim SearchText As String
    2. DIm URLSourceCode as String
    3.  
    4. URLSourceCode = Inet1.OpenURL(txtURL.Text, icString)
    5. SearchText = "flash.swf?Live=717759220.txt"
    6.  
    7. Instr(1, URLSourceCode, SearchText)

    thanks for u nice code. But the problem is that i do not know the sequence number in before that is random numbers but the rest of pattern is always the same and it exist onces in the html par. My main goal is to get those numbers before .txt and in whole page it is mentioned once . So i hope i get some help here.Thanks

  5. #5
    Oi, fat-rag! bushmobile's Avatar
    Join Date
    Mar 2004
    Location
    on the poop deck
    Posts
    5,592

    Re: How to retrive a perticuler line of html code using Inet1.OpenURL

    i updated my post, perhaps that will work for you?

  6. #6
    PowerPoster lintz's Avatar
    Join Date
    Mar 2003
    Location
    The 19th Hole
    Posts
    2,697

    Re: How to retrive a perticuler line of html code using Inet1.OpenURL

    Bushy, "flash.swf?Live=717759220.txt" may not end at the end of the line.

    Perphaps a better option would be to check for the next space after flahs.swf?

    VB Code:
    1. Private Function GetLine(ByVal sText As String, ByVal sFind As String) As String
    2.     Dim lPos As Long, lEnd As String
    3.     lPos = InStr(1, sText, sFind, vbTextCompare)
    4.     If lPos Then
    5.         lEnd = InStr(lPos, sText, " ")
    6.         If lEnd Then
    7.             GetLine = Mid$(sText, lPos, lEnd - lPos - 1)
    8.         Else
    9.             GetLine = Mid$(sText, lPos)
    10.         End If
    11.     End If
    12. End Function
    13.  
    14. ' Call it like:
    15. sLine = GetLine(RichTextBox1.Text, "flash.swf")

  7. #7
    Oi, fat-rag! bushmobile's Avatar
    Join Date
    Mar 2004
    Location
    on the poop deck
    Posts
    5,592

    Re: How to retrive a perticuler line of html code using Inet1.OpenURL

    Quote Originally Posted by tony007
    Note the number before .exe is changing so i want that nunber and the rest of the line.
    lintz, I was going off of the above quote, but yes, it may not be what he wants

  8. #8

    Thread Starter
    Frenzied Member
    Join Date
    Apr 2005
    Posts
    1,907

    Re: How to retrive a perticuler line of html code using Inet1.OpenURL

    Thanks for all of u for your nice reply. First thing could u guys tell me how i can call and use your functions and output it to textbox/RichTextBox1 ? This is what i want :


    <param name="movie" value="mp3player.swf?playlist=717764307.txt" />

    bold part is dynamic and i just want this output :mp3player.swf?playlist=717764307.txt in text box not the rest of html and stuff.Thanks

  9. #9
    PowerPoster lintz's Avatar
    Join Date
    Mar 2003
    Location
    The 19th Hole
    Posts
    2,697

    Re: How to retrive a perticuler line of html code using Inet1.OpenURL

    Your original post asked for "flash.swf" but now you're asking for "mp3player.swf"?

    Does this part change as well?

    As for calling the function bushmobile wrote, check the post as he tells you how to call it.

    To then show it in a text box simply add.....
    VB Code:
    1. txtCode = sLine

  10. #10
    Oi, fat-rag! bushmobile's Avatar
    Join Date
    Mar 2004
    Location
    on the poop deck
    Posts
    5,592

    Re: How to retrive a perticuler line of html code using Inet1.OpenURL

    Here's another version (with minor corrections):
    VB Code:
    1. Private Function GetLine(ByVal sText As String, ByVal sStart As String, ByVal sEnd As String) As String
    2.     Dim lPos As Long, lEnd As String
    3.     lPos = InStr(1, sText, sStart, vbTextCompare)
    4.     If lPos Then
    5.         lEnd = InStr(lPos, sText, sEnd)
    6.         If lEnd Then
    7.             GetLine = Mid$(sText, lPos, lEnd - lPos) & sEnd
    8.         Else
    9.             GetLine = Mid$(sText, lPos)
    10.         End If
    11.     End If
    12. End Function
    13.  
    14. ' It returns a string so just use it like:
    15. Text1.Text = GetLine(RichTextBox1.Text, "mp3player.swf?playlist=", ".txt")

  11. #11

    Thread Starter
    Frenzied Member
    Join Date
    Apr 2005
    Posts
    1,907

    Re: How to retrive a perticuler line of html code using Inet1.OpenURL

    Bushmobile i added another text box and button to my form and i called

    Text1.Text = GetLine(RichTextBox1.Text, "mp3player.swf?playlist=", ".txt")

    from on button click even. unfortuently i get same data in both text box. The first buton pulls out all the html and the second button that supposed to filter the output it gives the same out put!! could u tell me what i am doing wrong. Basicly i want

    mp3player.swf?playlist=717764307.txt part of the following line.Tanks

    <param name="movie" value="mp3player.swf?playlist=717764307.txt" />


    Code:
    Private Sub Command1_Click(Index As Integer)
    
    Select Case Index
        Case 0:
            If txtURL.Text <> "" Then
                RichTextBox1.Text = Inet1.OpenURL(txtURL.Text, icString)
                
            End If
        
        Case 1:
            End
    End Select
    End Sub
    
    
    Private Function GetLine(ByVal sText As String, ByVal sStart As String, ByVal sEnd As String) As String
        Dim lPos As Long, lEnd As String
        lPos = InStr(1, sText, sFind, vbTextCompare)
        If lPos Then
            lEnd = InStr(lPos, sText, sEnd)
            If lEnd Then
                GetLine = Mid$(sText, lPos, lEnd - lPos - 1) & sEnd
            Else
                GetLine = Mid$(sText, lPos)
            End If
        End If
    End Function
    
    ' It returns a string so just use it like:
    'Text1.Text = GetLine(RichTextBox1.Text, "mp3player.swf?playlist=", ".txt")
    Private Sub Command2_Click()
    Text1.Text = GetLine(RichTextBox1.Text, "mp3player.swf?playlist=", ".txt")
    
    End Sub

  12. #12
    Oi, fat-rag! bushmobile's Avatar
    Join Date
    Mar 2004
    Location
    on the poop deck
    Posts
    5,592

    Re: How to retrive a perticuler line of html code using Inet1.OpenURL

    well it works fine for me, and even if it wasn't working it shouldn't give you all the text it should give you none. Perhaps paste your code (edit: you have done) or upload your project.

  13. #13
    PowerPoster lintz's Avatar
    Join Date
    Mar 2003
    Location
    The 19th Hole
    Posts
    2,697

    Re: How to retrive a perticuler line of html code using Inet1.OpenURL

    Tony, you've got a combination of bushmobiles examples.

    Change this.....
    VB Code:
    1. Private Function GetLine(ByVal sText As String, ByVal [B]sStart[/B] As String, ByVal sEnd As String) As String

    to

    VB Code:
    1. Private Function GetLine(ByVal sText As String, ByVal [B]sFind[/B] As String, ByVal sEnd As String) As String

  14. #14
    Oi, fat-rag! bushmobile's Avatar
    Join Date
    Mar 2004
    Location
    on the poop deck
    Posts
    5,592

    Re: How to retrive a perticuler line of html code using Inet1.OpenURL

    Ahh, that'll be it. Good spot lintz.

    Alternatively turn:
    VB Code:
    1. lPos = InStr(1, sText, sFind, vbTextCompare)
    to
    VB Code:
    1. lPos = InStr(1, sText, sStart, vbTextCompare)

    That's what happens when you start fiddling around with variable names half-way through giving an example

  15. #15
    PowerPoster lintz's Avatar
    Join Date
    Mar 2003
    Location
    The 19th Hole
    Posts
    2,697

    Re: How to retrive a perticuler line of html code using Inet1.OpenURL

    The smallest change in your code can keep you going round in circles for hours looking for why it doesn't work

    Tony, is everything OK once you've make the change.??

  16. #16

    Thread Starter
    Frenzied Member
    Join Date
    Apr 2005
    Posts
    1,907

    Re: How to retrive a perticuler line of html code using Inet1.OpenURL

    Oh thanks for u replys. I finally got it working . i used this one ;


    Code:
    Private Sub Command1_Click(Index As Integer)
    
    Select Case Index
        Case 0:
            If txtURL.Text <> "" Then
                RichTextBox1.Text = Inet1.OpenURL(txtURL.Text, icString)
            End If
        
        Case 1:
            End
    End Select
    End Sub
    
    
    Private Sub Command2_Click()
    ' It returns a string so just use it like:
    Text1.Text = GetLine(RichTextBox1.Text, "mp3player.swf?playlist=", ".txt")
    End Sub
    Private Function GetLine(ByVal sText As String, ByVal sStart As String, ByVal sEnd As String) As String
        Dim lPos As Long, lEnd As String
        lPos = InStr(1, sText, sStart, vbTextCompare)
        If lPos Then
            lEnd = InStr(lPos, sText, sEnd)
            If lEnd Then
                GetLine = Mid$(sText, lPos, lEnd - lPos) & sEnd
            Else
                GetLine = Mid$(sText, lPos)
            End If
        End If
    End Function
    May i know if those changes that u guys posted are required since the old one worked well. furthermore, do u think this code will not make problem if there were a few spaces after the .txt?

    Furthermore , Now for another page there are many patern like this :
    ../player/player.asp?id=16412')"> and i am just interested in value of integers after the = shown in bold. I tried the same code but changed it to

    Text1.Text = GetLine(RichTextBox1.Text, "../player/player.asp?id= ", "')")

    for some reason i only get only one out but i know fur sure there are like 9 of those type of patternt wth diffrent numbers. I hope u guys tell me what i am doing wrong again.Thanks
    Last edited by tony007; Apr 24th, 2006 at 09:02 PM.

  17. #17
    Oi, fat-rag! bushmobile's Avatar
    Join Date
    Mar 2004
    Location
    on the poop deck
    Posts
    5,592

    Re: How to retrive a perticuler line of html code using Inet1.OpenURL

    shouldn't make a difference what's after the .txt

    lEnd As String needs to be changed to lEnd As Long

    (it was wrong in my post)

    to get more than one occurance of the pattern you can write the values into an array i.e:

    VB Code:
    1. Private Sub Command1_Click()
    2.     Dim sResult() As String, N As Long
    3.  
    4.     If GetLine(RichTextBox1.Text, "../playr/player.asp?id=", "')", sResult) Then
    5.         ' Occurances were found and have been placed in the array
    6.         ' we'll just Debug.Print them
    7.         For N = LBound(sResult) To UBound(sResult)
    8.             Debug.Print sResult(N)
    9.         Next N
    10.     Else
    11.         ' No occurances were found
    12.     End If
    13. End Sub
    14.  
    15. Private Function GetLine(ByVal sText As String, ByVal sStart As String, ByVal sEnd As String, ByRef sArr() As String) As Boolean
    16.     Dim lPos As Long, lEnd As Long, lCount As Long, sTemp() As String
    17.    
    18.     ReDim sTemp(100)
    19.    
    20.     lPos = InStr(1, sText, sStart, vbTextCompare)
    21.     Do While lPos
    22.         lEnd = InStr(lPos, sText, sEnd, vbTextCompare)
    23.         If lEnd Then
    24.             sTemp(lCount) = Mid$(sText, lPos, lEnd - lPos) & sEnd
    25.             lPos = InStr(lEnd, sText, sStart, vbTextCompare)
    26.         Else
    27.             sTemp(lCount) = Mid$(sText, lPos)
    28.             lPos = 0
    29.         End If
    30.         lCount = lCount + 1
    31.         If lCount > UBound(sTemp) Then ReDim Preserve sTemp(100 + lCount)
    32.     Loop
    33.  
    34.     If lCount > 0 Then
    35.         ReDim Preserve sTemp(lCount - 1)
    36.         sArr = sTemp
    37.     End If
    38.     GetLine = lCount
    39. End Function

  18. #18
    PowerPoster lintz's Avatar
    Join Date
    Mar 2003
    Location
    The 19th Hole
    Posts
    2,697

    Re: How to retrive a perticuler line of html code using Inet1.OpenURL

    You would have to use a loop to find each occurance within the source code.

    VB Code:
    1. Dim LineArray() As String
    2.  
    3. Private Sub Command1_Click()
    4. Dim i As Integer
    5. ' It returns a string so just use it like:
    6. GetLine RTB1.Text, "../player/player.asp?id=", "')"
    7.  
    8. For i = LBound(LineArray) + 1 To UBound(LineArray)
    9. Debug.Print LineArray(i)
    10. Next
    11.  
    12. End Sub
    13. Private Sub GetLine(ByVal sText As String, ByVal sStart As String, ByVal sEnd As String)
    14.     Dim lPos As Long, lEnd As String, GetLine As String
    15.     Erase LineArray
    16.     ReDim LineArray(0)
    17.    lPos = InStr(1, sText, sStart, vbTextCompare)
    18.    
    19. Do Until lPos = 0
    20.  
    21.     If lPos Then
    22.         lEnd = InStr(lPos, sText, sEnd)
    23.         If lEnd Then
    24.             GetLine = Mid$(sText, lPos, lEnd - lPos)
    25.         Else
    26.             GetLine = Mid$(sText, lPos)
    27.         End If
    28.    
    29.         ReDim Preserve LineArray(UBound(LineArray) + 1)
    30.         LineArray(UBound(LineArray)) = GetLine
    31.         lPos = InStr(lPos + 1, sText, sStart, vbTextCompare)
    32.     End If
    33.    
    34. Loop
    35. End Sub


    EDIT: I'm little slow this morning bushmobile

  19. #19

    Thread Starter
    Frenzied Member
    Join Date
    Apr 2005
    Posts
    1,907

    Re: How to retrive a perticuler line of html code using Inet1.OpenURL

    Many thanks for both of u. bushmobile could u tell me how to remoe the ') from output and alos outupt it to a textbox .Thanks

    ../player/player.asp?id=16419 == just like this.

  20. #20
    PowerPoster lintz's Avatar
    Join Date
    Mar 2003
    Location
    The 19th Hole
    Posts
    2,697

    Re: How to retrive a perticuler line of html code using Inet1.OpenURL

    Remove & sEnd from the below line.

    VB Code:
    1. sTemp(lCount) = Mid$(sText, lPos, lEnd - lPos) & sEnd

    To display in a text box (maybe a listbox would be better)....

    VB Code:
    1. For N = LBound(sResult) To UBound(sResult)
    2. List1.Add sResult(N)
    3. Next N
    Last edited by lintz; Apr 24th, 2006 at 09:59 PM.

  21. #21
    Oi, fat-rag! bushmobile's Avatar
    Join Date
    Mar 2004
    Location
    on the poop deck
    Posts
    5,592

    Re: How to retrive a perticuler line of html code using Inet1.OpenURL

    to put it in a textbox:
    VB Code:
    1. For N = LBound(sResult) To UBound(sResult)
    2.     Text1.Text = Text1.Text & sResult(N) & vbCrLf
    3. Next N
    but as lintz said, a listbox might be more suitable.

  22. #22

    Thread Starter
    Frenzied Member
    Join Date
    Apr 2005
    Posts
    1,907

    Re: How to retrive a perticuler line of html code using Inet1.OpenURL

    Quote Originally Posted by lintz
    Remove & sEnd from the below line.

    VB Code:
    1. sTemp(lCount) = Mid$(sText, lPos, lEnd - lPos) & sEnd

    To display in a text box (maybe a listbox would be better)....

    VB Code:
    1. For N = LBound(sResult) To UBound(sResult)
    2. List1.Add sResult(N)
    3. Next N

    Many many thanks to u i tried the listbox code but it gives me compile error. Could u tell me how to fix it and also make the output in accending order.Thanks

  23. #23
    Oi, fat-rag! bushmobile's Avatar
    Join Date
    Mar 2004
    Location
    on the poop deck
    Posts
    5,592

    Re: How to retrive a perticuler line of html code using Inet1.OpenURL

    do you have a listbox named list1 on your form? What is the error (and on what line)?

    the easiest way to put it in order would be to set the .Sorted property of the ListBox to True

  24. #24

    Thread Starter
    Frenzied Member
    Join Date
    Apr 2005
    Posts
    1,907

    Re: How to retrive a perticuler line of html code using Inet1.OpenURL

    Quote Originally Posted by bushmobile
    do you have a listbox named list1 on your form? What is the error (and on what line)?

    the easiest way to put it in order would be to set the .Sorted property of the ListBox to True
    compile error: method or date member not found

    and point to this line
    List1.Add sResult(N)

    Code:
    Private Sub Command2_Click()
     Dim sResult() As String, N As Long
    
        If GetLine(RichTextBox1.Text, "Albums.asp?SingerID=", "&Singer=", sResult) Then
            ' Occurances were found and have been placed in the array
            ' we'll just Debug.Print them
            'For N = LBound(sResult) To UBound(sResult)
               ' Debug.Print sResult(N)
            'Next N
            
            'list box code
            
            
            For N = LBound(sResult) To UBound(sResult)
                  List1.Add sResult(N)
            Next N
    
        Else
            ' No occurances were found
        End If
    End Sub

  25. #25
    Oi, fat-rag! bushmobile's Avatar
    Join Date
    Mar 2004
    Location
    on the poop deck
    Posts
    5,592

    Re: How to retrive a perticuler line of html code using Inet1.OpenURL

    it should be AddItem

  26. #26

    Thread Starter
    Frenzied Member
    Join Date
    Apr 2005
    Posts
    1,907

    Re: How to retrive a perticuler line of html code using Inet1.OpenURL

    Quote Originally Posted by bushmobile
    to put it in a textbox:
    VB Code:
    1. For N = LBound(sResult) To UBound(sResult)
    2.     Text1.Text = Text1.Text & sResult(N) & vbCrLf
    3. Next N
    but as lintz said, a listbox might be more suitable.
    This one put all after each other. how i can make each one in seperate line to make i readable.Thanks

  27. #27
    Oi, fat-rag! bushmobile's Avatar
    Join Date
    Mar 2004
    Location
    on the poop deck
    Posts
    5,592

    Re: How to retrive a perticuler line of html code using Inet1.OpenURL

    make sure the textbox multiline property = True

  28. #28
    Oi, fat-rag! bushmobile's Avatar
    Join Date
    Mar 2004
    Location
    on the poop deck
    Posts
    5,592

    Re: How to retrive a perticuler line of html code using Inet1.OpenURL

    Did you get this all sorted in the end?

    If so you should mark the thred as resolved.

  29. #29

    Thread Starter
    Frenzied Member
    Join Date
    Apr 2005
    Posts
    1,907

    Re: How to retrive a perticuler line of html code using Inet1.OpenURL

    Quote Originally Posted by bushmobile
    Did you get this all sorted in the end?

    If so you should mark the thred as resolved.
    welll i actually got problem that for all my html request i get
    same output which is not correct. If i user make the same request using web browser it gives me diffrent output which is correct.I do not know the old data is not cleaned up inside my vb program or something that i get same output all the time. Could u look at the code and explaination at the following post and help me fix this problem.Thanks

    http://www.vbforums.com/showpost.php...61&postcount=1

  30. #30

    Thread Starter
    Frenzied Member
    Join Date
    Apr 2005
    Posts
    1,907

    Re: How to retrive a perticuler line of html code using Inet1.OpenURL

    Bushmbile thanks alot for u assitance . That problem solved it was the script problem not vb problem!! now i want do the following :

    How to use the Id= numbers to construct the follwoing URL and put it in text box for further manipulation

    Code:
    http://www.mysite/player/player.asp?sender=java&Id=16142&Id=16143&Id=16144&Id=16145
    Now the application only outputs all ids like this :

    ../player/player.asp?id=16142
    ../player/player.asp?id=16143
    .....
    .....
    .....
    Now I only want to use alll id values and construct this url :
    I be happy if u guys help me.Thanks

    Code:
    http://www.mysite/player/player.asp?sender=java&Id=16142&Id=16143&Id=16144&Id=16145
    Note:I want still keep the current output in listbox and textbox but just want a new text box with value of constructed URL in it ready to manipulate it.



    code:


    Code:
    Private Sub Command1_Click(Index As Integer)
    
    Select Case Index
        Case 0:
            If txtURL.Text <> "" Then
                RichTextBox1.Text = Inet1.OpenURL(txtURL.Text, icString)
            End If
        
        Case 1:
            End
    End Select
    End Sub
    
    
    Private Sub Command2_Click()
     Dim sResult() As String, N As Long
    
        If GetLine(RichTextBox1.Text, "../player/player.asp?id=", "')", sResult) Then
            ' Occurances were found and have been placed in the array
            ' we'll just Debug.Print them
            'For N = LBound(sResult) To UBound(sResult)
            '    Debug.Print sResult(N)
            'Next N
            
            For N = LBound(sResult) To UBound(sResult)
              List1.AddItem sResult(N)
              Text1.Text = Text1.Text & sResult(N) & vbCrLf
    
            Next N
    
            
            
            
        Else
            ' No occurances were found
        End If
    End Sub
    
    
    
    
    Private Function GetLine(ByVal sText As String, ByVal sStart As String, ByVal sEnd As String, ByRef sArr() As String) As Boolean
        Dim lPos As Long, lEnd As Long, lCount As Long, sTemp() As String
        
        ReDim sTemp(100)
        
        lPos = InStr(1, sText, sStart, vbTextCompare)
        Do While lPos
            lEnd = InStr(lPos, sText, sEnd, vbTextCompare)
            If lEnd Then
            'Remove & sEnd from the below line.
            'sTemp(lCount) = Mid$(sText, lPos, lEnd - lPos) & sEnd
                sTemp(lCount) = Mid$(sText, lPos, lEnd - lPos)
                lPos = InStr(lEnd, sText, sStart, vbTextCompare)
            Else
                sTemp(lCount) = Mid$(sText, lPos)
                lPos = 0
            End If
            lCount = lCount + 1
            If lCount > UBound(sTemp) Then ReDim Preserve sTemp(100 + lCount)
        Loop
    
        If lCount > 0 Then
            ReDim Preserve sTemp(lCount - 1)
            sArr = sTemp
        End If
        GetLine = lCount
    End Function
    Last edited by tony007; Apr 25th, 2006 at 10:17 AM.

  31. #31
    Oi, fat-rag! bushmobile's Avatar
    Join Date
    Mar 2004
    Location
    on the poop deck
    Posts
    5,592

    Re: How to retrive a perticuler line of html code using Inet1.OpenURL

    VB Code:
    1. If GetLine(RichTextBox1.Text, "../player/player.asp?id=", "')", sResult) Then
    2.         ' Occurances were found and have been placed in the array
    3.         ' we'll just Debug.Print them
    4.         'For N = LBound(sResult) To UBound(sResult)
    5.         '    Debug.Print sResult(N)
    6.         'Next N
    7.        
    8.         Text1.Text = "http://www.mysite/player/player.asp?sender=java"
    9.  
    10.         For N = LBound(sResult) To UBound(sResult)
    11.           List1.AddItem sResult(N)
    12.           Text1.Text = Text1.Text & "&id=" & Split(sResult(N), "=")(1)
    13.  
    14.         Next N

  32. #32

    Thread Starter
    Frenzied Member
    Join Date
    Apr 2005
    Posts
    1,907

    Re: How to retrive a perticuler line of html code using Inet1.OpenURL

    Many many thanks bushmobile that worked like magic. Now this code produces output like this for given url:

    output result in text box
    mp3player.swf?playlist=717834611.txt

    how to produce output that uses the number before .txt ONLY and construct the following type of
    url and put it in textbox:

    sample of url that i want to produce for numbers before .txt and place it in textbox
    Code:
    http://localhost/player/717834611.txt


    Code:
    Private Sub Command1_Click(Index As Integer)
    
    Select Case Index
        Case 0:
            If txtURL.Text <> "" Then
                RichTextBox1.Text = Inet1.OpenURL(txtURL.Text, icString)
            End If
        
        Case 1:
            End
    End Select
    End Sub
    
    
    Private Sub Command2_Click()
    ' It returns a string so just use it like:
    Text1.Text = GetLine(RichTextBox1.Text, "mp3player.swf?playlist=", ".txt")
    End Sub
    Private Function GetLine(ByVal sText As String, ByVal sStart As String, ByVal sEnd As String) As String
        Dim lPos As Long, lEnd As String
        lPos = InStr(1, sText, sStart, vbTextCompare)
        If lPos Then
            lEnd = InStr(lPos, sText, sEnd)
            If lEnd Then
                GetLine = Mid$(sText, lPos, lEnd - lPos) & sEnd
            Else
                GetLine = Mid$(sText, lPos)
            End If
        End If
    End Function

  33. #33
    Oi, fat-rag! bushmobile's Avatar
    Join Date
    Mar 2004
    Location
    on the poop deck
    Posts
    5,592

    Re: How to retrive a perticuler line of html code using Inet1.OpenURL

    This? (untested)
    VB Code:
    1. Private Sub Command2_Click()
    2. ' It returns a string so just use it like:
    3. Text1.Text = "http://localhost/player/" & GetLine(RichTextBox1.Text, "mp3player.swf?playlist=", ".txt")
    4. End Sub
    5.  
    6. Private Function GetLine(ByVal sText As String, ByVal sStart As String, ByVal sEnd As String) As String
    7.     Dim lPos As Long, lEnd As String
    8.     lPos = InStr(1, sText, sStart, vbTextCompare)
    9.     If lPos Then
    10.         lEnd = InStr(lPos, sText, sEnd)
    11.         If lEnd Then
    12.             GetLine = Mid$(sText, lPos + Len(sStart), lEnd - (lPos + Len(sStart))) & sEnd
    13.         Else
    14.             GetLine = Mid$(sText, lPos + Len(sStart))
    15.         End If
    16.     End If
    17. End Function

  34. #34

    Thread Starter
    Frenzied Member
    Join Date
    Apr 2005
    Posts
    1,907

    Re: How to retrive a perticuler line of html code using Inet1.OpenURL

    many thanks i tried but for some reasons it outputed the html files after the .txt tooo!! How i can remove that part.Thanks
    Last edited by tony007; Apr 25th, 2006 at 01:15 PM.

  35. #35
    Oi, fat-rag! bushmobile's Avatar
    Join Date
    Mar 2004
    Location
    on the poop deck
    Posts
    5,592

    Re: How to retrive a perticuler line of html code using Inet1.OpenURL

    when i do:

    VB Code:
    1. Debug.Print "http://localhost/player/" & GetLine("dfasfdfdfdsamp3player.swf?playlist=717834611.txtadfasdfdfasfd", "mp3player.swf?playlist=", ".txt")
    It works fine - (gives me: http://localhost/player/717834611.txt)

    Are you perhaps appending som text to the textbox elsewhere?

  36. #36

    Thread Starter
    Frenzied Member
    Join Date
    Apr 2005
    Posts
    1,907

    Talking Re: How to retrive a perticuler line of html code using Inet1.OpenURL

    Thanks alot i fixed that problem. Now i got a text box that has the following data on it :


    Code:
    <?xml version="1.0" encoding="UTF-8" ?> 
    - <player showDisplay="yes" showPlaylist="yes" autoStart="yes">
      <song path="http://www.mysite.com/TtdlI3l1lIl0OOO0a/singer1/album1/song1.mp3" title="song title" /> 
      <song path="http://www.mysite.com/TtdlI3l1lIl0OOO0a/singer1/album1/songname2.mp3" title="song title 2" /> 
      
      </player>
    could u show me how i can get the song path and title part only and be able to use them and input them in to mysql database .?

  37. #37
    Oi, fat-rag! bushmobile's Avatar
    Join Date
    Mar 2004
    Location
    on the poop deck
    Posts
    5,592

    Re: How to retrive a perticuler line of html code using Inet1.OpenURL

    Well, if you look over (and try to understand) the code I've provided you with so far I'm sure you'll be able to extract the data yourself. Regarding the mysql, search the forum and you'll find lots of previous threads.

    I'm not going to write your program for you.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width