|
-
Oct 19th, 2012, 06:17 PM
#1
Thread Starter
Frenzied Member
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>
-
Oct 19th, 2012, 06:46 PM
#2
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]
-
Oct 19th, 2012, 08:26 PM
#3
Thread Starter
Frenzied Member
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
-
Oct 19th, 2012, 09:01 PM
#4
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
-
Oct 19th, 2012, 09:03 PM
#5
Re: How to download and save a webpage and load its html in textbox?
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|