How to access the elements in a aspx page hold by the webbrowser control
Hi, Everyone:
I am new to vb and this forums. What I am trying to do is to write an automation program for our sales. The program needs to auto login to our customer's web site, then go a aspx page to get a sales table from customer's database. I am using a webbrowser control navigate to the customer site, and was able to automatically login and jump to the aspx page directly. I can see the web page in the webbrowser control window and the code in the code window. But when I trying to access its elements. that is trying to assign value of the element in order to extract certain data from the database, somehow I failed. The error message said there is no object exist, so the value is NULL. I am not quite understand this?
Can anyone point me a direction? Or give me some example of how to access the elements in a aspx page.
Thanks a lot.
Re: How to access the elements in a aspx page hold by the webbrowser control
Welcome to the forums jchi1207 :wave:
Are you doing this in asp.net or some other language?
Re: How to access the elements in a aspx page hold by the webbrowser control
Looks like plain old Web scraping to me. Probably belongs in one of the programming language forums but I guess we can't tell which.
The whole description smells a lttle funny though. To sell to customers you scrape data from their sites? Hopefully this isn't just spelunking these customers' contact info for spamming purposes.
Re: How to access the elements in a aspx page hold by the webbrowser control
Quote:
Originally Posted by
koolsid
Welcome to the forums jchi1207 :wave:
Are you doing this in asp.net or some other language?
Hi, Koolsid:
Thanks for the reply. I am doing this in VB 2010 express. I was able to auto login to this web site, and directly jump to the inquiry form (for the sales data). But somehow I could not access the elements in the page. If I use manual process, I will first login to the website, then select the menu item twice to enter the inquiry form. After log in to the web site, the page actually is composed by 3 frames. (the inquiry form is one of the page frame). What I am doing is directly jump to the page display only the inquiry form.
Hope you guys can help me. I am quite new to the web programming.
Re: How to access the elements in a aspx page hold by the webbrowser control
I tried some new method last week, and now I could not even jump to the frame page anymore. Maybe I should sates what I had done to clear this issue.
I first use webBrowser navigagte to the customer's website,
Then do the auto login
Me.wbTest.Document.GetElementById("txtUSER_ID").InnerText = "myid"
Me.wbTest.Document.GetElementById("txtUSER_PASSWORD").InnerText = "mypassword"
Me.wbTest.Document.GetElementById("tb_CheckDA").InnerText = validation code
Me.wbTest.Document.GetElementById("btnOK").InvokeMember("click")
Me.wbTest.Document.Window.DomWindow.execscript(_doPostBack())
Although VB issue me an error saying this javascript was protected, but still I was able to jump to the data request form.
This form was composed by 3 frames, top.aspx, home.aspx, and menu.aspx
when I click the option from the menu.aspx frame, it will post the data request form in home.aspx frame's area.
I garbed the URL from the menu.aspx page, and was able to navigate to the request form in a web browser.
But when I did the same in my program to ask the webbrowser to navigate to that URL, it back into the login page.
( https://b2b.tk3c.com.tw/tk3cb2b/B2BC...ProdNM=Nothing)
Can anyone tell me why? And how can I navigate to the data request frame page and access its input elements to automate the process?
Re: How to access the elements in a aspx page hold by the webbrowser control
Quote:
Originally Posted by
jchi1207
Hi, Koolsid:
Thanks for the reply. I am doing this in VB 2010 express.
Moved to Visual Basic .NET from General Developer Forum