-
Re: Manipulate/Change/Form Fill data in webpages using the Webbrowser control
Very good! It works.
One last question, is there a good way to parse the price.
<td class="priceBlockLabelPrice">Price:</td>
<td><b class="priceLarge">$26.05</b>
Right now I loop block element and find class name priceLarge. It looks not very safe or stable.
Appreciate your help.
-
Re: Manipulate/Change/Form Fill data in webpages using the Webbrowser control
by the way, I have several operations, each click/submit wil take some time , the second operation is based the first operation result. In this case, how to avoid the second operation is too fast and doesn't run it if not get the first page result return. I tried sleep a while but looks like it will sleep the first operation too. multi-thread? thanks.
-
Re: Manipulate/Change/Form Fill data in webpages using the Webbrowser control
no unfortunately, when you automate someone elses site, you are doing something they didnt intend or design for, so you get lots of cases where data you want doesn't have any easy way to access it other than some raw parsing. The downside is that when the page changes at all, it could break your parsing logic. However the same is true if they change something like an elements id value, which is generally considered the "easy way" to get data from a page.
As far as your question about timing, you need to use the documentcompleted event of the browser to do subsequent navigations and operations. This is the event that fires when a page fully loads into the browser and has been rendered. If you try to do ANYTHING to a webpage before this event fires, you will likely end up with an error sooner or later, because the page has not fully loaded.
So then people always ask the same question "well documentcompleted is only 1 event, and I need to do something different based on what page is actually loading", and the answer to that is you need to evaluate the browsers current URL when this event occurs, and that tells you which page just loaded, and you can take appropriate action from there.
Again, the process of manipulating webpages is a tricky one, and some sites are way easier than others. However I have done a few consulting projects and personal projects for web automation, and so far there was not a site I couldn't automate. Some projects require more maintenance than others, but that is just how it goes.
-
Re: Manipulate/Change/Form Fill data in webpages using the Webbrowser control
Thanks, Kleinma
You looks always online. What a great help!
I can imagine what we can not automate is the website you have to download a client(java program) on your computer.
-
Re: Manipulate/Change/Form Fill data in webpages using the Webbrowser control
well yes, I was strictly speaking from an HTML/Javascript manipulation standpoint. Things like java applets and activex controls may have some automation capabilities, but it would be done totally different than the HTML manipulation.
-
Re: Manipulate/Change/Form Fill data in webpages using the Webbrowser control
Hi Kleinma,
Nice weekend. I met another problem.
When I submit a button, it works at most time but it will prompt a error dialog sometime which make it can not proceed. I have to click to close the dialog. What was I missing? Thanks a lot.
The error dialog is
Title is Internet Explorer Script Error
An error has occurred in the script on this page.
Line: 72
Char: 1
Error: Invalid argument
Code: 0
URL: xxxx
Do you want to continue running scripts on this page?
Here is my code to submit:
webBrowser.Document.forms.item(, 0).elements("twotabsearchtextbox").value = txtField1.Text
'webBrowser.Document.forms.item(, 0).submit()
The following is the form html:
<form style="width:100%; margin:0 0 0 0; border:0; padding:0 0 0 0;" method="get" action="/s/ref=nb_ss_vg" name="site-search">
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td class="navSearchLeft"><img src="transparent-pixel._V42752373_.gif" width="58px" alt="Search" height="38px" border="0" /></td>
<td width="100" class="navSearchBar"><select name="url" class="searchSelect" title="Search in">
<option value="search-alias=aps">xxx.com</option>
<option value="search-alias=videogames" selected="selected">Video Games</option>
<option value="search-alias=videogames-used">Used Video Games</option>
</select></td>
<td width="3px" class="navSearchBar"> </td>
<td class="navSearchBar" align='left'><input type="text" id="twotabsearchtextbox" class="searchSelect" name="field-keywords" value="" size="50" title="Search for" style="width:100%; background-color: #FFF;" /></td>
<td align="right" width="3px" class="navSearchBar"> </td>
<td width="25" align="left">
<div id="navGoButton">
<input type="image" src=transparent-pixel._V42752373_.gif alt="Go" id="navGoButtonPanel"
onmouseover="shiftImage('navGoButtonPanel',0,-38,'navGoButton',2,1,1);"
onmouseout="shiftImage('navGoButtonPanel',0,0,'navGoButton',2,0,1);"
onfocus="shiftImage('navGoButtonPanel',0,-38,'navGoButton',2,1,1);"
onblur="shiftImage('navGoButtonPanel',0,0,'navGoButton',2,0,1);" />
</div>
</td>
</tr>
</table>
</form></td>
-
1 Attachment(s)
Re: Manipulate/Change/Form Fill data in webpages using the Webbrowser control
kleinma, I want to do an auto login using webbrowser, I already done the auto-fill username and password in the form, but the web site contain the verify code. How to get the verify code from the showing picture? Any idea?
The web site is : http://www.17mso.com
-
Re: Manipulate/Change/Form Fill data in webpages using the Webbrowser control
that picture looks to be the equivelant of a captcha verification, so no, there is no way to get around a captcha, except to write some code that can exame the image and determine the characters from the image.
The whole point of sites putting captcha verification on them, is to prevent automation of their site. To force an actual person to be there filling in the form.
-
Re: Manipulate/Change/Form Fill data in webpages using the Webbrowser control
Hi Kleinma,
Can you help me take a look above #366 problem? I suspect I need setup some properties/add some parameters manually for the embedded browser since IE works ok.
thanks.
-
Re: Manipulate/Change/Form Fill data in webpages using the Webbrowser control
kleinma, many thanks for your superb tutorial, everything i know about html has been learnt from this thread
i am trying to automate tradeXfair.com*WITHOUT THE X, can login and progress to the main page, but then it becomes proper difficult, my first question
is it true that if it is on the webpage it can be automated?
the parsing of the final webpage returns very little, i have managed to glean the info that there are 47 elements, cannot find id, name or any thing else about them, although theire are children, same again no info can be gleaned
anyway i tried invoke a click on the child, (not knowing which), and the website returned "HTTP 403 Forbidden, website declined to show page
while navigating to the page, i have noticed info regarding cursor position
could this be the reason for the decline?. is it possible the website is checking the position of my cursor to stop automation?
-
Re: Manipulate/Change/Form Fill data in webpages using the Webbrowser control
Hi kleinma, First thanks for sharing all this. It's been really usefull. Im working on some automation on a site containing AJAX on some processes. The problem is when I analize html code (on pages with AJAX) because (.net 2008) webbrowser shows me source of original html page (the one that loaded first).
Is there any workarround to solve this? I need the html source code of updated page (after ajax's been executed).
I have tried
wb.nabigate("javascript:'<xmp>' + window.document.body.outerHTML + '</xmp>'") with no success, but curiosly it works fine when pasted on IE. Am I missing something?
Thanks again.
Ariel
-
Re: Manipulate/Change/Form Fill data in webpages using the Webbrowser control
Hi, thanks for the source you have provided but im going for something a bit different and i couldnt seem to figure out your src to well. I dont want a webbrowser, not one thats visible anyway but i want it to log into the website automatically with no actualy input from the user. apart from username and password
Code:
Public Class Form1
Public Event DocumentCompleted As WebBrowserDocumentCompletedEventHandler
Dim instance As WebBrowser
Dim handler As WebBrowserDocumentCompletedEventHandler
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
AddHandler instance.DocumentCompleted, handler
instance.Navigate("http://www.warez-bb.org/login.php")
End Sub
Private Sub WebBrowser1_DocumentCompleted(ByVal sender As Object, ByVal e As WebBrowserDocumentCompletedEventArgs) Handles WebBrowser1.DocumentCompleted
.Document.Forms(0).All("username") = "dreadfear"
instance.Document.Forms(0).All("username") = "*****"
instance.Document.Forms(0).All("submit").Click()
End Sub
End Class
I cant seem to place anything inside of the form boxes or get it to click submit, any help is greatly appreciated im having alot of troulbe with this.
Thanks in advance.
-
Re: Manipulate/Change/Form Fill data in webpages using the Webbrowser control
just put the webbrowser control off the visible portion of the form. It needs to actually be visible for the automations to work (being visible and being able to see it don't have to be the same thing).
You could also do something like putting the webbrowser in a panel, and covering it with another control that is set docked to fill to cover over the browser control.
You usually do want SOME way for the user to be able to actually view the webpage, in the event automation fails for some reason, like the page doesn't load properly, it times out, it has changed and your automation no longer works, etc...
-
Re: Manipulate/Change/Form Fill data in webpages using the Webbrowser control
Hi, I have 2 questions. I am tring to automate a file upload/download process and here is the html code:
<input type="file" name="FileUpload1" id="FileUpload1">
<input type="submit" name="btnUpload" value="Update" id="btnUpload">
1. The SetAttribute("value", "c:\file1.xls") does not work. Which property should I use?
2. The submit button does two things - upload the specified file and then download another file, say file2.xls. How do I catch the file2.xls?
Thanks!
-
Re: Manipulate/Change/Form Fill data in webpages using the Webbrowser control
Quote:
Originally Posted by kleinma
just put the webbrowser control off the visible portion of the form. It needs to actually be visible for the automations to work (being visible and being able to see it don't have to be the same thing).
You could also do something like putting the webbrowser in a panel, and covering it with another control that is set docked to fill to cover over the browser control.
You usually do want SOME way for the user to be able to actually view the webpage, in the event automation fails for some reason, like the page doesn't load properly, it times out, it has changed and your automation no longer works, etc...
Ok thats good but how do i actually get it to fill in forms or get it to click a button, i have no idea how to do that and no tutorial i find knows either, ive been searching for a long time :(
-
Re: Manipulate/Change/Form Fill data in webpages using the Webbrowser control
Hello, I need help, I am using VB 2008
Here is what I want to do, first I want auto fill a textbox in my web browser and then submit it, and after that I want to retrieve data from the text on the web page and paste it into the textbox in my program,
-
Re: Manipulate/Change/Form Fill data in webpages using the Webbrowser control
Quote:
Originally Posted by dreadfear
Ok thats good but how do i actually get it to fill in forms or get it to click a button, i have no idea how to do that and no tutorial i find knows either, ive been searching for a long time :(
I am struggling with the web automation for the last few weeks too. Hope this would help.
dim mBrowserCompletedas boolean
Private sub Form_Load
'--- open the web page and wait for it to finish
mBrowserCompleted= false
WebBrowser1.Navigate("www.mysite.com")
WaitForBrowserToComplete()
'--- enter all the fields
webbrowser1.document.all("field1").SetAttribute("Value") = "abc"
webbrowser1.document.all("field2").SetAttribute("Value") = "xyz"
...
'--- submit the form and wait for the response
mBrowserCompleted= false
webbrowser1.document.Forms(0).InvokeMember("submit")
WaitForBrowserToComplete
'--- do whatever ...
end sub
Private sub WaitForBrowserToComplete()
do
application.DoEvents
loop until mBrowserCompleted
end sub
Private sub Webbrowser1_DocumentCompleted(.......)...
application.DoEvents
mBrowserCompleted= True
end sub
-
Re: Manipulate/Change/Form Fill data in webpages using the Webbrowser control
Quote:
Originally Posted by J. Jethro
Hello, I need help, I am using VB 2008
Here is what I want to do, first I want auto fill a textbox in my web browser and then submit it, and after that I want to retrieve data from the text on the web page and paste it into the textbox in my program,
Take a look at my post( #377). To retrieve data from the text on the web page and paste it into the textbox in your program:
txtField1.Text = Webbrowser1.document.all(field1").GetAttribute("Value").ToString()
...
-
Re: Manipulate/Change/Form Fill data in webpages using the Webbrowser control
Well, I am not sure if this is where I need to post this but others sent me think ing it was so here I go.
I have some info on a web page I want to put into my app I am making.
I will show what I would most like to do but then end with any work arounds or things I might have to just settle with if it can be done at all ...
OK .... Here is the link to the web site http://www.tulsapolice.org/udsw.html
About middle way down you will see an area called Current calls ... this little box area contains the current police calls for my area .... oh by the way ... it refreshes every 60 seconds .. keep that in mind ...
Within in this box area or frame or div or whatever you call it it contains two main peices of information
1. Description ie; Theft
2. Location ie; 123 Some Street Tulsa Ok
Ideally I would like to be able to get this updated info every 60 seconds and put it into my form/app displaying them in some control ... maybe a listbox or listview or perhaps just strait to an xml file .... dont matter just as long as its something I can access the info ....
Ok, I am not a web guru ... so maybe I am over looking the obvious and this info cant be accessed that way .. so ... how about option 2 then
Just grab the whole box/frame/div and display it in my app just like its seen on the page .... but .... get the updated info every 60 seconds ...
NOTE: This really doesnt allow me to do what I would most like ... as I am hoping to be able to access the info so I can keep record of what crimes are happening within certain areas ....
Well, I hope I have explained good enough as to what I am hoping I can do ... so, can you point me in the right direction ....
Mark
-
Re: Manipulate/Change/Form Fill data in webpages using the Webbrowser control
well the first thing to do when you want to automate a website or screen scrape data from a site is look at the site source HTML to see what you are dealing with.
They are using ASP.NET it looks like, and that table is probably getting written out on the fly from the server, and unfortunatly, they don't attach any name or id attributes to the table tags for the data you want.
This doesn't make it impossible, just more of a pain because when you have some sort of unique attribute identifier, it makes it very easy to grab the specific elements of the DOM you want, and parse the data.
Instead, you have to do something like grab all the tables in the DOM, and find the table that has a TD with inner text containing "Current Calls". Then you know you have gotten the right table element, and you can parse it from there. Just keep in mind as soon as they decide to change the page at all, your code likely will break and need to be modified. That is the nature of automating someones website that has not designed their site with automation in mind.
-
Re: Manipulate/Change/Form Fill data in webpages using the Webbrowser control
Yes, I looked at the source and it seems if I am looking at this right this is where it is all happening.
Code:
<div id="udecalls">
<iframe name="UDSW" width="520" src="http://www.cityoftulsa.org/divisions/divisions.aspx?div=udsw" height="222"> Your browser does not support inline frames or is currently configured not to display inline frames.</iframe>
</div>
Its in an iframe within a div called udecalls ..... however the url itself seems interesting .... hmmm could it be this is what we are looking at being displayed int he iframe???
I will look into that and check it out.
If so I may simply be able to display that but still this doesnt help me actually grab the info .. instead it would only let me display it ...
I will check out if I can display it but would love to be able to actually read it ...
Any thoughts will be appreciated
Ill be back after I test the url
Mark
-
Re: Manipulate/Change/Form Fill data in webpages using the Webbrowser control
Yep, this url http://www.cityoftulsa.org/divisions....aspx?div=udsw
Actually will allow me to display it on my app just as it is seen within the iframe.
However ..... could you give me any insight as to how I would actually display it on my app and how would tell my app to refresh it every 60 seconds?
Or point me to where I can find this out ...
Mean while I will do some searching on what control I will need ... thinking its webbrowser control ... but will reasearch it ...
Be back later
Mark
Oh thanx for pointing me to the source code
-
Re: Manipulate/Change/Form Fill data in webpages using the Webbrowser control
Ok I think I have this figured out ... well at least I have figured out that the info should be easily accessable ... I just dont know for sure how to parse this sort of info but let me give you an idea what I think then you can tell me where I am going wrong ...
:)
Ok this url http://www.cityoftulsa.org/divisions....aspx?div=udsw
It shoots the contents of what is in the frame that we are seeing on the page
I simply put the url in my browser and wa la I can see exactly what is on their web page.
But can I get the info from it ... yes I would think it would not be so hard ... dont know how yet as I do not know how to parse this following info but here it goes...
First click on the url above and you will see the data I need to parse especially if you view the source code of the above url
It will look like this ... this is actually a cut paste of the source code
Code:
<TABLE style="BORDER-RIGHT-STYLE: solid; BORDER-RIGHT-COLOR: black" cellSpacing="0" cellPadding="0"
width="475" border="1">
<TR>
<TD style="FONT-WEIGHT: bold; FONT-SIZE: 14pt; COLOR: darkkhaki; FONT-STYLE: italic; FONT-FAMILY: Arial; BACKGROUND-COLOR: black"
noWrap align="center"><FONT face="Times New Roman">Current Calls</FONT></TD>
</TR>
<TR style="FONT-WEIGHT: bolder; FONT-FAMILY: Arial" align="left">
<TD style="FONT-WEIGHT: bold; FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: arial; BACKGROUND-COLOR: white"> <FONT face="Times New Roman" size="3">Calls
Assigned to Officers</FONT></TD>
</TR>
<tr>
<td style="BACKGROUND-COLOR: white"><table cellspacing="0" cellpadding="4" rules="all" border="4" id="dgCurrent" style="color:Black;background-color:White;border-color:Black;border-width:4px;border-style:None;font-family:Times New Roman;font-size:X-Small;width:475px;border-collapse:collapse;">
<tr style="color:Black;background-color:White;font-family:Times New Roman;font-size:X-Small;font-weight:bold;">
<td>Description</td><td>Location</td>
</tr><tr style="color:Black;background-color:White;">
<td>Traffic Stop</td><td>4800 S YALE AVE </td>
</tr><tr style="color:Black;background-color:White;">
<td>Traffic Stop</td><td>5200 S LEWIS AVE </td>
</tr><tr style="color:Black;background-color:White;">
<td>Traffic Stop</td><td>3400 E BAWB EXPY </td>
</tr><tr style="color:Black;background-color:White;">
<td>Non Injury Collision</td><td>FAIRGROUNDS @4100 E 21 ST S </td>
</tr><tr style="color:Black;background-color:White;">
<td>Robbery Alarm</td><td>2400 E 32 ST S </td>
</tr><tr style="color:Black;background-color:White;">
<td>Larceny</td><td>2000 E 81 ST S </td>
</tr><tr style="color:Black;background-color:White;">
<td>Larceny</td><td>7100 S SHERIDAN RD </td>
</tr><tr style="color:Black;background-color:White;">
<td>Pickup Found Property</td><td>5300 S YALE AVE #1100 </td>
</tr><tr style="color:Black;background-color:White;">
<td>Pickup Runaway Juvenile</td><td>1100 S FULTON AVE </td>
</tr><tr style="color:Black;background-color:White;">
<td>Suspect at Scene</td><td>3700 W 53 PL S </td>
</tr><tr style="color:Black;background-color:White;">
<td>Suspect in Custody</td><td>4100 S YALE AVE </td>
</tr>
</table>
Sorry for it being so much ... but as you can see it shows the info I need to grab
Ok the question is ... how do I grab this source code from this url and then parse it for the needed info?
Any ideas anyone as to where I can see how to parse this ?
Mark
-
Re: Manipulate/Change/Form Fill data in webpages using the Webbrowser control
Ok .... here is what I have tried so far I think I might be on the right track however this code is not pulling all the info into the string as I thought so I am obviously going about this the wrong way
heres the code I am using though maybe it will spark some ideas
As I simply want to parse the source or the url
Code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim strHtml As String
strHtml = GetPageHtml("http://www.cityoftulsa.org/divisions/divisions.aspx?div=udsw/")
rtbParse.Text = strHtml
End Sub
Public Function GetPageHtml(ByVal URL As String) As String
Dim objWC As New System.Net.WebClient()
Return New System.Text.UTF8Encoding().GetString(objWC.DownloadData(URL))
End Function
Any thoughts?
Mark
-
Re: Manipulate/Change/Form Fill data in webpages using the Webbrowser control
-
Re: Manipulate/Change/Form Fill data in webpages using the Webbrowser control
Ok I have done a lot of searching and playing with various code ... some of it I sort of get the idea of how it works and but find I do not yet understand it enough to over come some trouble s I am getting into ...
Ok ... you were right ... this is not going to be an easy task ... but its one I am not yet giving up on as I am getting close ... or at least feel I am ...
I though I would show what I have done ... what results I am getting and then just maybe you might point out how I can improve on it ..
Ok using link I found it would not parse the html because of &nsb < or something like that ... they had to be removed also it would not parse the metta data for some reason but if the two were removed from the html it parsed it just fine ...
So before I write code to remove them which I found some examples of who to do this ....
I decided to remove them myself and practice with the parsing side of the code ...
Here is the code and html being parsed .....
Code:
Dim html = <html>
<head>
<title>Current UDSW calls</title>
</head>
<body>
<table style="border-right-style: solid; border-right-color: black;" border="1" cellpadding="0" cellspacing="0" width="475">
<tbody><tr>
<td style="font-weight: bold; font-size: 14pt; color: darkkhaki; font-style: italic; font-family: Arial; background-color: black;" align="center" nowrap="nowrap"><font face="Times New Roman">Current Calls</font></td>
</tr>
<tr>
<td style="background-color: white;"><table id="dgCurrent" style="border: 4px none Black; color: Black; background-color: White; font-family: Times New Roman; font-size: x-small; width: 475px; border-collapse: collapse;" border="4" cellpadding="4" cellspacing="0" rules="all">
<tbody><tr style="color: Black; background-color: White; font-family: Times New Roman; font-size: x-small; font-weight: bold;">
<td>Description</td><td>Location</td>
</tr><tr style="color: Black; background-color: White;">
<td>Non Injury Collision</td><td>6500 S YALE AVE </td>
</tr><tr style="color: Black; background-color: White;">
<td>Attempt to Serve Warrant</td><td>1200 S QUAKER AVE </td>
</tr><tr style="color: Black; background-color: White;">
<td>Burglary from Vehicle</td><td>4100 S YALE AVE </td>
</tr><tr style="color: Black; background-color: White;">
<td>Intoxicated Pedestrian</td><td>2500 W 47 ST S </td>
</tr><tr style="color: Black; background-color: White;">
<td>Fraud</td><td>4400 E 31 ST S </td>
</tr><tr style="color: Black; background-color: White;">
<td>Fraud</td><td>5900 E 56 ST S </td>
</tr><tr style="color: Black; background-color: White;">
<td>Hazard</td><td>1900 E 71 ST S </td>
</tr><tr style="color: Black; background-color: White;">
<td>Larceny</td><td>9500 S DELAWARE AVE </td>
</tr><tr style="color: Black; background-color: White;">
<td>Parking Violation</td><td>1900 S CINCINNATI AVE </td>
</tr><tr style="color: Black; background-color: White;">
<td>Receive Information</td><td>SK-NIMITZ @3100 E 56 ST S </td>
</tr>
</tbody></table></td>
</tr>
<tr>
<td id="TD1" style="background-color: white;" align="center">6 calls awaiting assignment</td>
</tr>
</tbody></table>
</body>
</html>
'''' ............. Below is my code ....................
Dim tabString = From ts In html...<tbody>
txt1.Text = tabString.Count()
For i = 0 To 24
ListBox1.Items.Add(tabString.<tr>.<td>(i).Value)
Next
Ok here is what I am getting ....
Listbox fills with the data .... almost perfect ... almost is the operative word
Lets say the data in the fields above was this for example
<td>1</td><td>2</td><td>3</td><td>4</td><td>5</td><td>6</td>
When it pulls out the data and is loaded in the listbox the data should look lik this
1
2
3
4
5
6
Instead it looks like this
1
123456
2
1
2
3
4
5
6
Weird .....
But hey, it was cool, cause I at least parsed it LOL
I about did the Walter Brennan dance ....
Ok ... not sure how to fix this I have tried several dozen attempts with not much improvement
ALSO .... as you can see in the For statement I i as interger a value of 0 to 24
Its because I know there are at the moment 24 <td>Items with data in them</td>
..... I need to figure out hwo to count them or make go to end and stop or something like that
I tried to do
Code:
For i As Integer = 0 to tabString.count
BUT, the valu of tabString.count is only 2 which means its only counting up to 3 and stopping but if I remove tabString and just put i = 0 to 24 it will go right to the end and do what it is supposed to do ...
Any thoughts how I can clean this up and or a better approach
Please ... I really want to pull this off no matter how much work and learning I got to do ...
Mark
-
Re: Manipulate/Change/Form Fill data in webpages using the Webbrowser control
Mark, I had time today to look at this for you finally.
Not sure exactly what you want to do with the data, but I did you up a quick parsing routine that will extract the data from the HTML and list it in 2 listboxes. You should be able to take this sample, and understand how to grab this data and do whatever you want with it.
So make a new WinForms project, and add a webbrowser control, and 2 listboxes
So you have Webbrowser1, Listbox1, Listbox2
Then paste this code into Form1
Code:
Private _URL As String = "http://www.cityoftulsa.org/divisions/divisions.aspx?div=udsw"
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
WebBrowser1.Navigate(_URL)
End Sub
Private Sub WebBrowser1_DocumentCompleted(ByVal sender As System.Object, ByVal e As System.Windows.Forms.WebBrowserDocumentCompletedEventArgs) Handles WebBrowser1.DocumentCompleted
'GET CURRENT CALLS TABLE
Dim myTable As HtmlElement = WebBrowser1.Document.All("dgCurrent")
'MAKE SURE WE GOT A VALID TABLE OBJECT
If myTable IsNot Nothing Then
'LOOP ALL ROW ELEMENTS IN TABLE
For Each MyElement As HtmlElement In myTable.GetElementsByTagName("TR")
'THERE SHOULD BE 2 TD ELEMENTS PER ROW
Dim myTDTags As HtmlElementCollection = MyElement.GetElementsByTagName("TD")
'IF WE GOT 2 TD ELEMENTS, WRITE THEM TO 2 LISTBOXES
If myTDTags.Count = 2 Then
ListBox1.Items.Add(myTDTags(0).InnerText)
ListBox2.Items.Add(myTDTags(1).InnerText)
End If
Next
End If
End Sub
run it and there you go ;)
-
Re: Manipulate/Change/Form Fill data in webpages using the Webbrowser control
WOW ....... :D
This works great ........... Now I am going to go play with it a bit se if I can modify it to drop the webBrowser control
Which looks like I can ..... we will see but none the less this is absolutely marvelous
Thank you
Mark
-
Re: Manipulate/Change/Form Fill data in webpages using the Webbrowser control
Worst case you could always set the browser to a very small size, and then set its location to a negative x/y value so its not actually visible on the form. I don't believe (can't remember off the top of my head) that the browser works properly if you just set its visible property to false. I have done projects where I simply cover over the browser control with a panel or something.
-
Re: Manipulate/Change/Form Fill data in webpages using the Webbrowser control
its full of errors with the "mshtml.*"
its all errors!!!
-
Re: Manipulate/Change/Form Fill data in webpages using the Webbrowser control
Yes but I cant help the fact their web master well isn't a web master but I can say this code has been fantastic .... I am also learning now how to parse html with linq and LINQ is amazingly simple and powerful stuff. Again ... cant thank you enough for assisting me with this ... since this code ... seeing how to actually access the html has really just been awesome .... I have used this very code exampl to allow me to now get info from several pages ..
Seeing it can be done has now as I said with LINQ to pull info and parse exact o specific info right from pages ....
ANyway thank you ... I learn so much by example .. I really appreciate you taking the time
Mark
-
Re: Manipulate/Change/Form Fill data in webpages using the Webbrowser control
Many of the concepts can be used in VB6, however the specific .NET code will not be a simple copy/paste into VB6.
If you know .NET and VB6 you could probably easily port this code over to VB6
If I ever have some free time, maybe I will try, since you are the second person to ask in just a few days, but for now its really just .NET 2003/2005
__________________
Hi,
In the very first page you said you will provide Manipulated code for "WebpageManipulation.zip" in VB6 also.
I am trying to fill a textbox and conduct a search on http://www.fujitsu-siemens.ie/suppor...ranty_ent.html through excel VBA.
But not being successful.
Could you provide code in VB6 and help to solve this problem?
-
Re: Manipulate/Change/Form Fill data in webpages using the Webbrowser control
I know both, but I don't have any plans to port this code over to an old language.
If anything, I will be updating this code for newer .NET versions.
-
Re: Manipulate/Change/Form Fill data in webpages using the Webbrowser control
Hi there kleinma! I absolutely worship you after reading the entire thread and observe how good you are in programming. How I wish I could be like you someday.
Well here's what I wanna ask help for. I am migrating from VB6 to VB 2008 since I was able to get the copy of the program already. I am a newbie to Web Controls, and here's the favor that I wanna ask you of.
I have a Wordpress enabled blog and I made a program that will auto generate the content within VB. All I wanna do is to create a button that will automatically transfer the contents to the web control that I made.
Here's the source code of the .php page when posting a new content:
Whew... It was too long. I'll send it to you instead.
Sorry if it have to be really long. That is the contents of the "add new content" part. I can't ask too much by letting you do the entire job. I just want to know how will I be able to define the fields within this form and how can I manipulate/fill them out using VB? Including just the check boxes and radio buttons.
All I wanted to do is have my text fields' content transferred correspondingly. Then have it execute the "publish" button, validate if the page is different (meaning the content is posted already) and proceed to another web page.
Hope you could help me out with this. I'd really appreciate it. Thanks and more power! :thumb:
-
Re: Manipulate/Change/Form Fill data in webpages using the Webbrowser control
Hi Kleinma,
Very good job, but I have one questions.
In a web page I try to fill three combobox and then click on submit button. Web pages is .aspx,
ComboBox in page
<label for="control28_ddDateOfPubMonth" id="control28_lbDateOfPubMonth" class="hide">Month</label><select name="control28$ddDateOfPubMonth" id="control28_ddDateOfPubMonth" class="date-month">
<option selected="selected" value="-1" disabled="disabled">Month</option>
<option value="1">January</option>
...
and button is
<a id="control28_btnSubmit" href="javascript:__doPostBack('control28$btnSubmit','')">Search</a>
How can I fill this three combo box from forms and then click onButton. This webPage do post back and I need render search result.
I'm desperate.
I try this
DirectCast(GetCurrentWebForm.item("control28_btnSubmit", 0), mshtml.HTMLButtonElement).click()
but dosen't work. Never Click on button in this page.
I try WebZinc but dosen't work.
-
Re: Manipulate/Change/Form Fill data in webpages using the Webbrowser control
From the HTML you posted, it looks like the submit mechanism on that page is an anchor (<A>) tag, and not an HTML Button. So casting it to an HTMLButtonElement is not going to do the trick.
Try casting it to a (I think the class name is) HTMLAnchorElement, and try calling click on that instead.
-
Re: Manipulate/Change/Form Fill data in webpages using the Webbrowser control
Tnx for you replay.
Do you mean
DirectCast(GetCurrentWebForm.item("control28_btnSubmit", 0), mshtml.HTMLAnchorElement).click()
when I do this I get NullReferenceException.
Another thing when I use this WebZinc componente I have this error
Server Error in '/' Application.
Invalid postback or callback argument. Event validation is enabled using <pages enableEventValidation="true"/> in configuration or <%@ Page EnableEventValidation="true" %> in a page.
Is it possible to make general automation on this web page???
-
Re: Manipulate/Change/Form Fill data in webpages using the Webbrowser control
Resolved my selecting of radio buttons with the following:
Code:
Dim theElementCollection2 As HtmlElementCollection = WebBrowser1.Document.GetElementsByTagName("Input")
For Each curElement As HtmlElement In theElementCollection2
Dim controlValue As String = curElement.GetAttribute("Value").ToString
If controlValue = "VALUETOSELECTHERE" Then
curElement.InvokeMember("click")
End If
Next
-
Re: Manipulate/Change/Form Fill data in webpages using the Webbrowser control
Thanks, I have solved my previous problem.
But now I have a different one.
Please open this URL http://support.euro.dell.com/support...dt1&l=en&s=bsd.
It will open Dell warranty search page. If service tag is blank kindly fill it with JNK630J. Now it will navigate you on a new page. On this newpage you will find a new link as Change Service Tag. If I click on the link it opens a new Dialogue and ask to enter new service tag no. I am not able to get the access of this dialogue box. I want to fill a new value in this box and want to click on Go.
How can I get access of this dialogue.
How can fill new no and click on Go.
-
Re: Manipulate/Change/Form Fill data in webpages using the Webbrowser control
Hi all im new to this one...
I am trying to make an app in vb.net (part of visual studio 2005) that will do the following:
goto website login page and attempt login
if login fail goto website signup page and attempt signup
if login or signup success then
goto upload page and auto fill upload page and submit.
I would like to do this for say 10 sites.
I have tried 2-3 and managed ok but found that that doing more is very difficult.
Does anyone have any ideas as to how i can keep track within the code of say different upload page form items from the different sites.
Basically I want to make an auto submitter for my video to different video sites and the test for different site form elements and their names are making my code huge...
Just wondering if anyone knows an easier way.
Thanks