Manipulating WebPage Content

Learn how to create Add-Ins of all types for V3-R and share your own tutorials with others.
1 post Page 1 of 1
Contributors
User avatar
CodenStuff
Site Admin
Site Admin
Posts: 4389
Joined: Tue Aug 04, 2009 1:47 am

Manipulating WebPage Content
CodenStuff
Hello,

How to manipulate a webpages content do things like auto-login, form filling, locating elements and executing clicks.

This is the quickest way at this current time to do this and its a very simple replacement for any code you already use. For example if you added a webbrowser control to a form and wanted it to goto a specific page you would use:
Code: Select all
WebBrowser1.Navigate("www.site.com")
And to use that same function in V3R from your add-in you simply change the code to this:
Code: Select all
CType(Parent.FindForm.Controls(MainPanel).Controls(WebPanel).Controls.Item(0).Controls(Browser), WebBrowser).Navigate("www.site.com")
If you wanted to get a list of images from your webbrowser and add the links into a listbox you would use this:
Code: Select all
For Each ImageLink As HtmlElement In WebBrowser1.Document.Images 
Listbox1.items.add(ImageLink.GetAttribute("src")) 
Next 
But to do the same thing from an add-in in V3R you would change the code to this:
Code: Select all
For Each ImageLink As HtmlElement In CType(Parent.FindForm.Controls(MainPanel).Controls(WebPanel).Controls.Item(0).Controls(Browser), WebBrowser).Document.Images 
Listbox1.items.add(ImageLink.GetAttribute("src")) 
Next 

And thats all their is to it. All you do is change "WebBrowser1" in your code to this:
Code: Select all
CType(Parent.FindForm.Controls(MainPanel).Controls(WebPanel).Controls.Item(0).Controls(Browser), WebBrowser)
That simply accesses the currently visible browser on the V3R screen which gives you access to do whatever you want with it cooll;

Remember this code WILL change on final release so keep your source-code so you can make any changes later otherwise any add-ins you make wont work when V3R is released properly :?
Welcome to CodenStuff.com Learn Code, Love Code. Thank you for being a member of the community.
1 post Page 1 of 1
Return to “Tutorials”