Results 1 to 5 of 5

Thread: How to download and save a webpage and load its html in textbox?

  1. #1

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

    How to download and save a webpage and load its html in textbox?

    hi all . i wonder how i can download a webpage and load its html in to a textbox for further processing. My main goal is to download a remote webpage and search for following value(want to get http://www.somesite.com/u/videoplaye...?mediaID=12345 ) in its source code. could any one show me how this can be done ? thanks


    HTML Code:
    <TABLE width="430" border="0" cellpadding="0" cellspacing="0" style="table-layout: fixed">
    <TR height="348">
    <!--  Player -->
    <TD width="430" bgcolor="#000000" align="center" valign="top"><IFRAME src="http://www.somesite.com/u/videoplayer/player.php?mediaID=12345" width="430" height="348" marginwidth="0" marginheight="0"  hspace="0" vspace="0" scrolling="no" frameborder="0" ></IFRAME></TD>
    </TR>
    <TR>
    <TD width="430"><IMG SRC="images/forCut_videoClipsNEW_09.jpg" WIDTH="430" HEIGHT="8" BORDER=0 ALT=""></TD>
    </TR>
    </TABLE>

  2. #2
    PowerPoster
    Join Date
    Aug 2011
    Location
    B.C., Canada
    Posts
    2,887

    Re: How to download and save a webpage and load its html in textbox?

    easy to do.. i will show example with Internet Explorer

    Code:
    Private Sub Form_Load()
    Dim IE As Object
    Set IE = CreateObject("InternetExplorer.Application")
      IE.Visible = False
      IE.Silent = True
      IE.Navigate "http://www.somesite.com/u/videoplaye...?mediaID=12345"
    
      Do Until IE.ReadyState = 4
        DoEvents
      Loop
      
      Do Until IE.document.ReadyState = "complete"
        DoEvents
      Loop
      
    Text1.Text = IE.document.body.innerhtml
    
    IE.Quit
    Set IE = Nothing
    Unload Me
    End Sub
    [/CODE]

  3. #3

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

    Re: How to download and save a webpage and load its html in textbox?

    Thanks max for your reply. I managed to load the html in to richtextbox but how to look for value of src="..." (in this case it would be http://www.somesite.com/u/videoplaye...D=12345)inside the html code and add it to listbox(in another word i want to extract src url from webbrowser html)?



    HTML Code:
    <TABLE width="430" border="0" cellpadding="0" cellspacing="0" style="table-layout: fixed">
    <TR height="348">
    <!--  Player -->
    <TD width="430" bgcolor="#000000" align="center" valign="top"><IFRAME src="http://www.somesite.com/u/videoplayer/player.php?mediaID=12345" width="430" height="348" marginwidth="0" marginheight="0"  hspace="0" vspace="0" scrolling="no" frameborder="0" ></IFRAME></TD>
    </TR>
    <TR>
    <TD width="430"><IMG SRC="images/forCut_videoClipsNEW_09.jpg" WIDTH="430" HEIGHT="8" BORDER=0 ALT=""></TD>
    </TR>
    </TABLE>

    Code:
    Private Sub Command6_Click()
    Dim strURL As String
    Dim objHTML
    
    
        strURL = WebBrowser2.LocationURL
        Set objHTML = CreateObject("Microsoft.XMLHTTP")
        objHTML.open "GET", strURL, False
        objHTML.send
    
        RichTextBox1.Text = objHTML.responseText
    
        Set objHTML = Nothing
    End Sub

  4. #4
    PowerPoster
    Join Date
    Aug 2011
    Location
    B.C., Canada
    Posts
    2,887

    Re: How to download and save a webpage and load its html in textbox?

    would this help

    Code:
    Dim TextLine() As String, SRCwebsite() As String, i As Integer, Pos As Integer
      TextLine = Split(Text1.Text, vbNewLine)
      List1.Clear
        For i = 0 To UBound(TextLine)
          Pos = InStr(1, LCase(TextLine(i)), "src=")
            If Pos <> 0 Then
               SRCwebsite = Split(Right(TextLine(i), Len(TextLine(i)) - Pos - Len("rc=")), """")
               List1.AddItem SRCwebsite(1)
            End If
        Next

  5. #5
    PowerPoster
    Join Date
    Aug 2011
    Location
    B.C., Canada
    Posts
    2,887

    Re: How to download and save a webpage and load its html in textbox?

    sorry duplicate post
    Last edited by Max187Boucher; Oct 19th, 2012 at 09:06 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