• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 285
  • Last Modified:

how to get html source from inet control

How to get html source from inet control

    Hi,
        i am trying to access html source code from vb inet control.
        but i am not getting full html source code of the give url
        for  eg:     htsource = Inet1.OpenURL(url, icString)
        whenever i am executing this line of code i got the html source
        differently.
        plz help me to solve this problem
    thanks
      Sobha
0
sobhamuktha
Asked:
sobhamuktha
  • 4
  • 2
  • 2
  • +1
1 Solution
 
hongjunCommented:
Have you tried downloading the latest service patch from Microsoft? SP4 fixed it.
0
 
Stephen MandersonCommented:
Hi there you could try this.



Dim strURL As String
Dim strHTML As String

strURL = "http://www.test.com"

With Inet1
.AccessType = icUseDefault
strHTML = .OpenURL(strURL)
End With

' Translate linefeeds into vbCrLFs if necessary.
If InStr(strHTML, Chr(10)) Then
strHTML = Replace$(strHTML, Chr(10), vbCrLf)
End If

txtHTML.Text = strHTML ' Fill a textbox with the source
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
Stephen MandersonCommented:
or if you want to get the url from a text box change the strURL to


strURL = txturl.text

providing you have a text box named txturl
0
 
sobhamukthaAuthor Commented:
hai,


With Inet1
.AccessType = icUseDefault
strHTML = .OpenURL(strURL)
End With


i even tried the above code but i am not getting full html source
plz help to get the full html source from vb programme using inet control and also help how to put the multiple request from inet control(after getting the urls from source i save those urls in the  database)


thanking you
regards
Sobha
0
 
Stephen MandersonCommented:
Hi there, i have made an example and uploades it too, www.sdm-group.com/source.zip Hope this sorts your problems.
0
 
Stephen MandersonCommented:
Are you usuing a Rich Text Box ? I used that in my example and had no problems.
0
 
sobhamukthaAuthor Commented:
hi all

i got the solution.


Dim htsource As Variant

Private Sub Command1_Click()
With Inet1
htsource = ""
d.Execute Text1.Text, "GET"
Do While .StillExecuting
    DoEvents
Loop
End With
Dim header As String
header = Inet1.GetHeader
MsgBox header
End Sub

Private Sub Inet1_StateChanged(ByVal State As Integer)
    Dim vtData As Variant       ' Data variable.
  '  Dim intFile As Integer      ' File number variable.
  '  intFile = FreeFile()        ' Get free file number.
    Select Case State
    ' ' Other cases not shown.
    '
    Case icResponseCompleted
        ' Open a file to write to.
   '     Open "c:\test\avant.htm" For Binary Access _
    '        Write As #intFile

        ' Get the first chunk. NOTE: specify a byte
        ' array (icByteArray) to retrieve a binary file.
        vtData = Inet1.GetChunk(1024, icString)
        htsource = htsource & vtData
        Do While LenB(vtData) > 0
   '         Put #intFile, , vtData
            ' Get next chunk.
            vtData = Inet1.GetChunk(1024, icString)
            htsource = htsource & vtData
        Loop
   '     Put #intFile, , vtData
   '    Close #intFile
   MsgBox "source" & htsource
    End Select
End Sub

Regards
Sobha
0
 
moduloCommented:
PAQed with points refunded (250)

modulo
Community Support Moderator
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 4
  • 2
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now