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

Web Objects

I have a vbscript that i'm currently using to copy the contents automatically from ie into notepad using SendKeys "^a^c" and then "^v".

I'd like to write a similar program using Visual Basic, however seeing as it's a more versatile language, there must be a better way to copy the textual content of the webobject.

Suggestions?
0
Lothian
Asked:
Lothian
1 Solution
 
singasCommented:
You can use the Webbrowser object on a form to display the chosen web page. Call the Navigate function of the Webbrowser control passing it the URL you wish to view.

When the page has finished downloading (you can wait for the Document Complete event to fire) you can access any of the objects on the webpage using the DOM.

For example if the object is an INPUT element (a text box) and it has an ID of 'Password' which is on a form called 'Login' you can access the contents of the text box in the document the same way you would if you were writting a script than ran in the page itself. 'Webbrowser1.Document.Login.Password' would reference the INPUT element. All you would need to do then is copy its text (Value) into a string.
0
 
aelatikCommented:
Here, this will fetch the source between the body tags ( you have to search for what you want inside the result of GetHTMLCode.

Private Sub Form_Load()
GetHTMLCode ("http://www.google.com")
End Sub

Public Function GetHTMLCode(URL As String)
  Dim IE
  Set IE = CreateObject("InternetExplorer.Application")
      IE.Navigate URL
      While IE.Busy
          DoEvents
      Wend
          GetHTMLCode = IE.Document.body.innerHTML
          'Replace above line with below if you want the entire page instead of the body tags
          'GetHTMLCode = IE.Document.documentelement.innerHTML
  MsgBox GetHTMLCode
End Function
0
 
LothianAuthor Commented:
What I actually need to do is access content that is generated to a table. So essentially, i need a text capture of the contents of that page for later parsing.

Thanks for the input though.
0

Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

Tackle projects and never again get stuck behind a technical roadblock.
Join Now