Results 1 to 35 of 35

Thread: Grab Html Source

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2006
    Posts
    448

    Arrow Grab Html Source

    My program grabs the html source, and I'm not sure how to seperate it enough just to get a certain part.. here is a section of the HTML..

    HTML Code:
    <tr>
    <td align=right>
    <font face=arial size="-1">AS&nbsp;DA:</font></td>
    <td><font face=arial size="-1"><b>John</b></font>
    </td>
    </tr>
    In the source of the entire page, there are many things like
    HTML Code:
    <font face=arial size="-1">
    I want to know how to find the John part somehow using the
    HTML Code:
    AS&nbsp;DA
    part to get it. Thanks for any help.
    "Remember, remember the 5th of November, the gun powder treason and plot. I know of no reason why the gun powder treason should ever be forgot."

  2. #2

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2006
    Posts
    448

    Re: Grab Html Source

    Any help with this? Anything is greatly appreciated
    "Remember, remember the 5th of November, the gun powder treason and plot. I know of no reason why the gun powder treason should ever be forgot."

  3. #3
    Fanatic Member
    Join Date
    Aug 2005
    Location
    South Africa
    Posts
    760

    Re: Grab Html Source

    If you want to find the text that is in the place of 'John', you could use this
    VB Code:
    1. Private Function FindName(HTML As String) As String
    2. Dim StartPt As Integer, EndPt As Integer
    3.  
    4. StartPt = Instr(1, HTML, "AS&nbsp;DA:</font></td>" & vbNewLine & "<td><font face=arial size=" & Chr(34) & "-1" & Chr(34) & "><b>")
    5. EndPt = Instr(StartPt, HTML, "</b></font>") - StartPt
    6.  
    7. FindName = Mid$(HTML, StartPt, EndPt)
    8. End Function
    Just call FindName() with the HTML source and it will return the name!

    Plz add to my reputation if this helped!
    If I helped you out, please consider adding to my reputation!

    -- "The faulty interface lies between the chair and the keyboard" --

    VB6 Programs By Me:
    ** Dictionary, Thesaurus & Rhyme-Generator In One ** WMP Recent Files List Editor ** Pretty Impressive Clock ** Extract Firefox History **

  4. #4

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2006
    Posts
    448

    Re: Grab Html Source

    Well, I'm not quite sure how to use this.. Maybe you can add in where i should put this and how.. or maybe just show me a simple source that downloads the html and includes that? Thanks..
    "Remember, remember the 5th of November, the gun powder treason and plot. I know of no reason why the gun powder treason should ever be forgot."

  5. #5
    Junior Member
    Join Date
    Jun 2006
    Posts
    21

    Re: Grab Html Source

    You could use the Split command to seperate it into sections...

  6. #6
    PowerPoster Static's Avatar
    Join Date
    Oct 2000
    Location
    Rochester, NY
    Posts
    9,390

    Re: Grab Html Source

    what are you tring to do... explain what you want the end result to be.

    how are you getting the source? inet? webbrowser? html object?
    JPnyc rocks!! (Just ask him!)
    If u have your answer please go to the thread tools and click "Mark Thread Resolved"

  7. #7
    Fanatic Member
    Join Date
    Aug 2005
    Location
    South Africa
    Posts
    760

    Re: Grab Html Source

    I provided you with a function that parses out the name from the HTML.

    You can use the Inet control to download the HTML source code and then send it to the FindName function which will return the name in the HTML.

    Add the Microsoft Internet Transfer Control to your components (CTRL + T) and then use this code when you have a command button named Command1 and an Inet control named Inet1 on your form
    VB Code:
    1. Private Sub Command1_Click()
    2. Dim htmlName As String
    3.  
    4. htmlName = FindName(Inet1.OpenURL("http://www.MY-URL-HERE.com"))
    5. MsgBox htmlName, vbInformation
    6. End Sub
    7.  
    8. Private Function FindName(HTML As String) As String
    9. Dim StartPt As Integer, EndPt As Integer
    10.  
    11. StartPt = Instr(1, HTML, "AS&nbsp;DA:</font></td>" & vbNewLine & "<td><font face=arial size=" & Chr(34) & "-1" & Chr(34) & "><b>")
    12. EndPt = Instr(StartPt, HTML, "</b></font>") - StartPt
    13.  
    14. FindName = Mid$(HTML, StartPt, EndPt)
    15. End Function
    This will connect to the website and then parse out the name contained in the HTML and display it in a message box
    Last edited by shirazamod; Jun 30th, 2006 at 02:41 PM.
    If I helped you out, please consider adding to my reputation!

    -- "The faulty interface lies between the chair and the keyboard" --

    VB6 Programs By Me:
    ** Dictionary, Thesaurus & Rhyme-Generator In One ** WMP Recent Files List Editor ** Pretty Impressive Clock ** Extract Firefox History **

  8. #8

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2006
    Posts
    448

    Re: Grab Html Source

    I tried doing what you said and all it does is highlight
    htmlName = FindName(Inet1.OpenURL("http://www.MY-URL-HERE.com"))
    "Remember, remember the 5th of November, the gun powder treason and plot. I know of no reason why the gun powder treason should ever be forgot."

  9. #9

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2006
    Posts
    448

    Re: Grab Html Source

    oh, nevermind that was dumb of me. I never put Inet on the form.
    "Remember, remember the 5th of November, the gun powder treason and plot. I know of no reason why the gun powder treason should ever be forgot."

  10. #10

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2006
    Posts
    448

    Re: Grab Html Source

    I tried again and all it does is wait a few seconds and then says Type Mismatch and highlights this line

    htmlName = FindName(Inet1.OpenURL("http://www.MY-URL-HERE.com"))
    "Remember, remember the 5th of November, the gun powder treason and plot. I know of no reason why the gun powder treason should ever be forgot."

  11. #11
    Fanatic Member
    Join Date
    Aug 2005
    Location
    South Africa
    Posts
    760

    Re: Grab Html Source

    You need to replace "MY-URL-HERE" with the URL to the page that you want to get the HTML from.

    If it works, please mark this thread Resolved & add to my reputation!!
    If I helped you out, please consider adding to my reputation!

    -- "The faulty interface lies between the chair and the keyboard" --

    VB6 Programs By Me:
    ** Dictionary, Thesaurus & Rhyme-Generator In One ** WMP Recent Files List Editor ** Pretty Impressive Clock ** Extract Firefox History **

  12. #12

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2006
    Posts
    448

    Re: Grab Html Source

    Yes, i already did replace that But i still get the error 'Type Mismatch'
    "Remember, remember the 5th of November, the gun powder treason and plot. I know of no reason why the gun powder treason should ever be forgot."

  13. #13
    Fanatic Member
    Join Date
    Aug 2005
    Location
    South Africa
    Posts
    760

    Re: Grab Html Source

    Please edit the code so that the first line of the FindName() function is
    VB Code:
    1. Debug.Print HTML
    And then post what the HTML is so that we can help
    If I helped you out, please consider adding to my reputation!

    -- "The faulty interface lies between the chair and the keyboard" --

    VB6 Programs By Me:
    ** Dictionary, Thesaurus & Rhyme-Generator In One ** WMP Recent Files List Editor ** Pretty Impressive Clock ** Extract Firefox History **

  14. #14

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2006
    Posts
    448

    Re: Grab Html Source

    VB Code:
    1. Private Sub Command1_Click()
    2. Dim htmlName As String
    3. Debug.Print HTML
    4. htmlName = FindName(Inet1.OpenURL("http://www.MY-URL-HERE.com"))
    5. MsgBox htmlName, vbInformation
    6. End Sub
    7.  
    8. Private Function FindName(HTML As String) As String
    9. Dim StartPt As Integer, EndPt As Integer
    10.  
    11. StartPt = Instr(1, HTML, "AS&nbsp;DA:</font></td>" & vbNewLine & "<td><font face=arial size=" & Chr(34) & "-1" & Chr(34) & "><b>")
    12. EndPt = Instr(StartPt, HTML, "</b></font>") - StartPt
    13.  
    14. FindName = Mid$(HTML, StartPt, EndPt)
    15. End Function
    Like that?
    "Remember, remember the 5th of November, the gun powder treason and plot. I know of no reason why the gun powder treason should ever be forgot."

  15. #15

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2006
    Posts
    448

    Re: Grab Html Source

    VB Code:
    1. Private Sub Command1_Click()
    2. Dim htmlName As String
    3. htmlName = FindName(Inet1.OpenURL("http://www.MY-URL-HERE.com"))
    4. MsgBox htmlName, vbInformation
    5. End Sub
    6.  
    7. Private Function FindName(HTML As String) As String
    8. Debug.Print HTML
    9. Dim StartPt As Integer, EndPt As Integer
    10.  
    11. StartPt = Instr(1, HTML, "AS&nbsp;DA:</font></td>" & vbNewLine & "<td><font face=arial size=" & Chr(34) & "-1" & Chr(34) & "><b>")
    12. EndPt = Instr(StartPt, HTML, "</b></font>") - StartPt
    13.  
    14. FindName = Mid$(HTML, StartPt, EndPt)
    15. End Function
    I tried putting it there also and it didn't make a difference..
    "Remember, remember the 5th of November, the gun powder treason and plot. I know of no reason why the gun powder treason should ever be forgot."

  16. #16
    Fanatic Member
    Join Date
    Aug 2005
    Location
    South Africa
    Posts
    760

    Re: Grab Html Source

    Like this, and then come back here and tell me what it printed:
    VB Code:
    1. Private Sub Command1_Click()
    2. Dim htmlName As String
    3.  
    4. htmlName = FindName(Inet1.OpenURL("http://www.MY-URL-HERE.com"))
    5. MsgBox htmlName, vbInformation
    6. End Sub
    7.  
    8. Private Function FindName(HTML As String) As String
    9. Dim StartPt As Integer, EndPt As Integer
    10. [b]Debug.Print HTML[/b]
    11.  
    12. StartPt = Instr(1, HTML, "AS&nbsp;DA:</font></td>" & vbNewLine & "<td><font face=arial size=" & Chr(34) & "-1" & Chr(34) & "><b>")
    13. EndPt = Instr(StartPt, HTML, "</b></font>") - StartPt
    14.  
    15. FindName = Mid$(HTML, StartPt, EndPt)
    16. End Function
    If I helped you out, please consider adding to my reputation!

    -- "The faulty interface lies between the chair and the keyboard" --

    VB6 Programs By Me:
    ** Dictionary, Thesaurus & Rhyme-Generator In One ** WMP Recent Files List Editor ** Pretty Impressive Clock ** Extract Firefox History **

  17. #17

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2006
    Posts
    448

    Re: Grab Html Source

    All it did was say type mismatch and higlight the same line again..
    "Remember, remember the 5th of November, the gun powder treason and plot. I know of no reason why the gun powder treason should ever be forgot."

  18. #18
    Fanatic Member
    Join Date
    Aug 2005
    Location
    South Africa
    Posts
    760

    Re: Grab Html Source

    ok then use this
    VB Code:
    1. Private Sub Command1_Click()
    2. Dim htmlName As String
    3.  
    4. htmlName = FindName(Inet1.OpenURL("http://www.MY-URL-HERE.com"))
    5. MsgBox htmlName, vbInformation
    6. End Sub
    7.  
    8. Private Function FindName(HTML As String) As String
    9. Dim StartPt As Integer, EndPt As Integer
    10. Open "C:\DEBUG.txt" For Output As #1
    11. Print #1, HTML
    12. Close #1
    13.  
    14. StartPt = Instr(1, HTML, "AS&nbsp;DA:</font></td>" & vbNewLine & "<td><font face=arial size=" & Chr(34) & "-1" & Chr(34) & "><b>")
    15. EndPt = Instr(StartPt, HTML, "</b></font>") - StartPt
    16.  
    17. FindName = Mid$(HTML, StartPt, EndPt)
    18. End Function
    And after it gives you the error go to your C:\ drive and look for a file called DEBUG.txt and post the contents of that file here
    REMEMBER to change the URL to the one where your file is
    If I helped you out, please consider adding to my reputation!

    -- "The faulty interface lies between the chair and the keyboard" --

    VB6 Programs By Me:
    ** Dictionary, Thesaurus & Rhyme-Generator In One ** WMP Recent Files List Editor ** Pretty Impressive Clock ** Extract Firefox History **

  19. #19

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2006
    Posts
    448

    Re: Grab Html Source

    It didn't even make the file.
    "Remember, remember the 5th of November, the gun powder treason and plot. I know of no reason why the gun powder treason should ever be forgot."

  20. #20
    Fanatic Member
    Join Date
    Aug 2005
    Location
    South Africa
    Posts
    760

    Re: Grab Html Source

    That's very strange.
    Add a breakpoint on the line that contains your URL and then step through the code using F8 to see exactly where the error occurs
    If I helped you out, please consider adding to my reputation!

    -- "The faulty interface lies between the chair and the keyboard" --

    VB6 Programs By Me:
    ** Dictionary, Thesaurus & Rhyme-Generator In One ** WMP Recent Files List Editor ** Pretty Impressive Clock ** Extract Firefox History **

  21. #21

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2006
    Posts
    448

    Re: Grab Html Source

    Well, your code doesn't seem to work :-// Oh well, I guess..
    "Remember, remember the 5th of November, the gun powder treason and plot. I know of no reason why the gun powder treason should ever be forgot."

  22. #22
    Fanatic Member
    Join Date
    Aug 2005
    Location
    South Africa
    Posts
    760

    Re: Grab Html Source

    You really don't appreciate what I've done.
    I've been trying to help you
    If I helped you out, please consider adding to my reputation!

    -- "The faulty interface lies between the chair and the keyboard" --

    VB6 Programs By Me:
    ** Dictionary, Thesaurus & Rhyme-Generator In One ** WMP Recent Files List Editor ** Pretty Impressive Clock ** Extract Firefox History **

  23. #23

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2006
    Posts
    448

    Re: Grab Html Source

    Yes, I really appreciate that. I've done everything you've said with no result. So, I guess I'm just giving up, as the code seems flawless and there's nowhere else we can take it to. Therefore, I say 'Oh Well'
    "Remember, remember the 5th of November, the gun powder treason and plot. I know of no reason why the gun powder treason should ever be forgot."

  24. #24
    PowerPoster Static's Avatar
    Join Date
    Oct 2000
    Location
    Rochester, NY
    Posts
    9,390

    Re: Grab Html Source

    add a reference to the Microsoft HTML Object Library

    VB Code:
    1. Dim HTML As New HTMLDocument
    2.     Dim tHTML As HTMLDocument
    3.     Dim TBL As HTMLTable
    4.     Dim ROW As HTMLTableRow
    5.     Dim CELL As HTMLTableCell
    6.     Dim NextCell As Boolean
    7.     HTML = tHTML.createDocumentFromUrl("http://www.URLHERE.com", vbNullString)
    8.     Do Until HTML.readyState = "complete"
    9.         DoEvents
    10.     Loop
    11.        
    12.     For Each TBL In HTML.getElementsByTagName("table")
    13.         For Each ROW In TBL.rows
    14.         NextCell = False
    15.             For Each CELL In ROW.cells
    16.                 Debug.Print CELL.innerText
    17.                 'this is just a guess since I cant see full source
    18.                 If NextCell Then
    19.                     MsgBox CELL.innerText
    20.                     NextCell = False
    21.                     Exit For
    22.                 End If
    23.                 If CELL.innerText = "AS DA:" Then
    24.                     NextCell = True
    25.                 End If
    26.             Next
    27.         Next
    28.     Next

    or.. actually Try this code:
    It work a little better.. but read the note in it.. ive never tried it like that..
    setting a CELL object using the cell index

    VB Code:
    1. Dim HTML As New HTMLDocument
    2.     Dim tHTML As HTMLDocument
    3.     Dim TBL As HTMLTable
    4.     Dim ROW As HTMLTableRow
    5.     Dim CELL As HTMLTableCell
    6.     Dim CELL2 As HTMLTableCell
    7.     HTML = tHTML.createDocumentFromUrl("http://www.URLHERE.com", vbNullString)
    8.     Do Until HTML.readyState = "complete"
    9.         DoEvents
    10.     Loop
    11.        
    12.     For Each TBL In HTML.getElementsByTagName("table")
    13.         For Each ROW In TBL.rows
    14.             For Each CELL In ROW.cells
    15.                 Debug.Print CELL.innerText
    16.                 'this is just a guess since I cant see full source
    17.                 If CELL.innerText = "AS DA:" Then
    18.                     'this code here is UNTESTED! lol..
    19.                     'ive never tried it this way before but it
    20.                     'might just work....
    21.                     Set CELL2 = ROW.cells(CELL.cellIndex + 1)
    22.                     MsgBox CELL2.innerText
    23.                     Exit For
    24.                 End If
    25.             Next
    26.         Next
    27.     Next
    JPnyc rocks!! (Just ask him!)
    If u have your answer please go to the thread tools and click "Mark Thread Resolved"

  25. #25

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2006
    Posts
    448

    Re: Grab Html Source

    Maybe you could be so kind as to show me an example on where this code can be used.. or a source :-/ or something
    "Remember, remember the 5th of November, the gun powder treason and plot. I know of no reason why the gun powder treason should ever be forgot."

  26. #26
    PowerPoster
    Join Date
    May 2006
    Posts
    2,988

    Re: Grab Html Source

    try something like this ..

    VB Code:
    1. Private Sub Command1_Click()
    2.     Dim i As String
    3.     i = getHTMLDocument("http://www.mywebsitepage.com")
    4.     If Len(i) Then
    5.         i = Replace(i, "AS", Chr(&H9F) & "AS")
    6.         Call ParseText(i)
    7.         'Text1 = i
    8.     End If
    9. End Sub
    10.  
    11. '// ADD SENTENCES TO TEXT BOX
    12. Private Sub ParseText(ByVal myString As String)
    13.     Dim sArray() As String
    14.     Dim sTemp As String
    15.     Dim sLine As String
    16.     Dim iLine As Integer
    17.     Dim e As Integer
    18.     sArray = Split(myString, Chr(&H9F))       ' SPLIT UP THE SENTENCES
    19.     iLine = 0
    20.     For e = 0 To UBound(sArray)             ' LOOP THROUGH EACH ONE
    21.         sTemp = Trim$(sArray(e))            ' GET RID OF SPACES AT ENDS
    22.         If Len(sTemp) > 0 Then              ' IF THERE IS MORE THAN 1 LETTER
    23.             iLine = iLine + 1               ' ADD NUMBERS TO LINES
    24.             sLine = Left(sTemp, InStr(sTemp, ":"))
    25.             If Len(sLine) Then
    26.                 Text1 = Text1 & "LINE " & iLine & ": " & sLine & vbCrLf
    27.                 Text1 = Text1 & "RESULTS: " & Replace(sTemp, sLine, "") & vbCrLf & vbCrLf
    28.             End If
    29.         End If
    30.     Next e
    31. End Sub
    32.  
    33. '// HTMLDOC *** GET TEXT FROM WEB PAGE **** REFERENCE REQUIRED
    34. Private Function getHTMLDocument(ByVal strUrl As String) As String
    35.     Dim HTML As New HTMLDocument
    36.     Dim DOC As HTMLDocument
    37.     Set DOC = HTML.createDocumentFromUrl(strUrl, vbNullString)
    38.     Do While DOC.readyState <> "complete"
    39.         DoEvents
    40.     Loop
    41.     getHTMLDocument = DOC.documentElement.innerText
    42. End Function

  27. #27

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2006
    Posts
    448

    Re: Grab Html Source

    Ok, all that did was take the text that is actually shown on the web page.. how am i supposed to find the 'John' part?
    "Remember, remember the 5th of November, the gun powder treason and plot. I know of no reason why the gun powder treason should ever be forgot."

  28. #28

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2006
    Posts
    448

    Re: Grab Html Source

    I'm guessing I do something like this..

    If temp(b) = "As Da:" Then temp (b + 1) And List1.AddItem(List1.ListIndex)

    I don't know ..
    "Remember, remember the 5th of November, the gun powder treason and plot. I know of no reason why the gun powder treason should ever be forgot."

  29. #29
    Junior Member
    Join Date
    Jun 2006
    Posts
    21

    Re: Grab Html Source

    Ok...well to find 'John' in that, use this once you have the HTML saved in a String variable. (Let's assume that the variable is called htmlStore, and it's public)

    VB Code:
    1. Private Function FindResult()
    2.  
    3. Dim HolderOne() as String
    4. Dim HolderTwo() as String
    5. Dim Result As String
    6.  
    7. HolderOne() = Split(htmlStore, "&nbsp;DA:</font></td>
    8. <td><font face=arial size="-1"><b>")
    9.  
    10. HolderTwo() = Split(HolderOne(1), "</b></font>")
    11.  
    12. Result = HolderTwo(0)
    13. MsgBox Result
    14.  
    15. End Function

    All this does is VERY SIMPLY find whatever the name is in the HTML. So, here is what you are going to do once you download the HTML using the INET control:

    STORE THE HTML IN A PUBLIC STRING NAMED htmlStore

    Then, call this function to find whatever the name is in the document.

    That's the easy part. If you don't get it then give up.

    Rate it if it works!

  30. #30

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2006
    Posts
    448

    Re: Grab Html Source

    When you told me to split this...

    HolderOne() = Split(htmlStore, "&nbsp;DA:</font></td>
    <td><font face=arial size="-1"><b>")


    VB won't let you split that, i just pasted it in and it turned RED.
    "Remember, remember the 5th of November, the gun powder treason and plot. I know of no reason why the gun powder treason should ever be forgot."

  31. #31

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2006
    Posts
    448

    Re: Grab Html Source

    That's the easy part. If you don't get it then give up.
    Also, Thanks for the encouragement.
    "Remember, remember the 5th of November, the gun powder treason and plot. I know of no reason why the gun powder treason should ever be forgot."

  32. #32

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2006
    Posts
    448

    Re: Grab Html Source

    Even when i tried what was used in the first post..

    HolderOne() = Split(htmlStore, "Real&nbsp;Name:</font></td>" & vbNewLine & "<td><font face=arial size=" & Chr(34) & "-1" & Chr(34) & "><b>")

    It just highlights the HolderTwo line and says subscript out of range.. The easy part eh?
    "Remember, remember the 5th of November, the gun powder treason and plot. I know of no reason why the gun powder treason should ever be forgot."

  33. #33
    Fanatic Member
    Join Date
    Aug 2005
    Location
    South Africa
    Posts
    760

    Re: Grab Html Source

    You can adapt my 'FindName' function from above to get the 'John' part out of the html
    If I helped you out, please consider adding to my reputation!

    -- "The faulty interface lies between the chair and the keyboard" --

    VB6 Programs By Me:
    ** Dictionary, Thesaurus & Rhyme-Generator In One ** WMP Recent Files List Editor ** Pretty Impressive Clock ** Extract Firefox History **

  34. #34
    Junior Member
    Join Date
    Jul 2006
    Posts
    22

    Re: Grab Html Source

    VB Code:
    1. Public Sub getName()
    2. On Error Resume Next
    3.  
    4. 'Get the text between search strings.
    5.     Dim sSource As String
    6.     Dim sFindStart As String, sFindEnd As String
    7.     Dim lStart As Long, lEnd As Long
    8.      sSource = Inet1.openUrl ("HTTP://www.yourwebsitehere.com")
    9.  
    10.  
    11.             'Initialize variables.
    12.         lStart = 1
    13.         lEnd = 1
    14.         sFindStart = "AS&nbsp;DA:</font></td><td><font face=arial size=" & Chr$(34) & "-1" & Chr$(34) & "><b>"
    15.         sFindEnd = "</b></font>"
    16.        
    17.     'Get the document text.
    18.  
    19.    
    20.     'Find the start position.
    21.         lStart = InStr(lStart, sSource, sFindStart, vbTextCompare)
    22.        
    23.         'Find the end postion only if the start text is found.
    24.             If lStart Then
    25.            
    26.                 'Add the length of the search text.
    27.                     lStart = lStart + Len(sFindStart)
    28.                
    29.                 lEnd = InStr(lStart, sSource, sFindEnd, vbTextCompare)
    30.                
    31.                 If lEnd > lStart Then
    32.                     Name =  Mid$(sSource, lStart, lEnd - lStart)
    33.                    
    34.                 Else
    35.                     Debug.Print "name End text not found."
    36.                 End If
    37.                
    38.             Else
    39.            
    40.                 Debug.Print "name Text not found."
    41.                
    42.             End If
    43. End Sub

    Add that code to your project, change the url in the Inet1.openurl line to your site, obviously you need to add an Inet control to your project. What it does is searches for the html directly in front of and following the text you wish to find and returns what is between.

    The error type mismatch was likely coming from the vbnewline in the code by shirazamod, I am betting it didn't find the start text. The mid function will error if it returns 0 for the start, that is why you need to initialize the variables and allow for the possibility that it won't find the start or finish points.
    Last edited by calder; Jul 1st, 2006 at 01:53 PM.

  35. #35
    PowerPoster
    Join Date
    May 2006
    Posts
    2,988

    Re: Grab Html Source

    Quote Originally Posted by k0zz
    I'm guessing I do something like this..

    If temp(b) = "As Da:" Then temp (b + 1) And List1.AddItem(List1.ListIndex)

    I don't know ..
    the results line is the part that gets the name.

    Text1 = Text1 & "RESULTS: " & Replace(sTemp, sLine, "") & vbCrLf & vbCrLf
    Last edited by rory; Jul 1st, 2006 at 01:58 PM.

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