|
-
Sep 26th, 2009, 01:23 PM
#1
Thread Starter
Frenzied Member
[RESOLVED] Read a Web Page Source / Attributes?
I'm updating an old VB6 program which uses the webbrowser control to navigate to a website and read some text from a text box.
i.e msgbox(Web.Document.All("Textbox2").Value)
Now I'm trying to replicate the same action in ASP .Net (aspx)
How do I go about this ?
_____________________________________________________________________
----If this post has helped you. Please take time to Rate it.
----If you've solved your problem, then please mark it as RESOLVED from Thread Tools.

-
Sep 26th, 2009, 01:59 PM
#2
Re: Read a Web Page Source / Attributes?
Hey,
I would suggest that you do this either using an HttpWebRequest:
http://msdn.microsoft.com/en-us/libr...ebrequest.aspx
Or a WebClient:
http://msdn.microsoft.com/en-us/libr...nt(VS.80).aspx
My personal preference would be to use the HttpWebRequest, and then look at the response that you get back.
If you search these forums for those terms, you should come up with a number of examples on both. Have a look, and then post back with any questions that you have.
Hope that helps!
Gary
-
Sep 27th, 2009, 05:16 AM
#3
Thread Starter
Frenzied Member
Re: Read a Web Page Source / Attributes?
Thanks, but I've been searching around and there is a lot mixed replies about this.
I've managed to get page source.. but haven't figured out how to SUBMIT or how to click on a button?
Is it with HttpWebResponse ?
Can any post an equivalent example to VB6's web browser control?
Code:
Web.Document.All("Textbox5").Value = convStr
Web.Document.All("Button4").Click
_____________________________________________________________________
----If this post has helped you. Please take time to Rate it.
----If you've solved your problem, then please mark it as RESOLVED from Thread Tools.

-
Sep 27th, 2009, 06:20 AM
#4
Re: Read a Web Page Source / Attributes?
There isn't an equivalent. You'll need to recreate the POST yourself, but this also means that you can't "read user input" that a user may have entered on the target page because the user isn't going to see the target page at all. You'll really need to explain the overall goal here (not the specifics as you've mentioned) so that we can tell you what to read up on. It's likely that you'll need to show the user your own form which in turn generates an HTTP POST and submits the target web page.
-
Sep 27th, 2009, 10:07 AM
#5
Thread Starter
Frenzied Member
Re: Read a Web Page Source / Attributes?
Well in simple terms this is what I'm trying to achieve.
Web PageX programatically submits some info to Web PageY
Web PageX waits until WebPageY processes the Info.
Only WebPageY has finished...
WebPageX retreives the info..
Original VB6 Code:
Code:
Web.Navigate PathToSite & "Reg.aspx?ID=" & txtNo.Text
WebPageY then executed this code and outputs it to a text box... in its own page:
Then there is:
Code:
Web.Document.All("Textbox5").Value = convStr
Web.Document.All("Button4").Click
I need to Invoke a button click...
This then outputs some info on other text boxes...
And finally WebPageX needs to retrieve this info.
Last edited by some1uk03; Sep 27th, 2009 at 10:17 AM.
_____________________________________________________________________
----If this post has helped you. Please take time to Rate it.
----If you've solved your problem, then please mark it as RESOLVED from Thread Tools.

-
Sep 27th, 2009, 10:11 AM
#6
Re: Read a Web Page Source / Attributes?
Hey,
Are these web pages that you have created within your application, or are these 3rd party websites, that you have no control over?
I am still a little confused by your intentions.
Gary
-
Sep 27th, 2009, 12:10 PM
#7
Re: Read a Web Page Source / Attributes?
Yes, you'll need to do an HttpWebRequest with a POST. You'll first have to look at the target page's structure, which fields it's expecting and then emulate those values.
-
Sep 27th, 2009, 12:34 PM
#8
Thread Starter
Frenzied Member
Re: Read a Web Page Source / Attributes?
 Originally Posted by gep13
Hey,
Are these web pages that you have created within your application, or are these 3rd party websites, that you have no control over?
Gary
Yes they are both mine.. so I do have full control over both.. But its just that one is at website1.com and website2.com
So they're not 2 pages within 1 domain...
_____________________________________________________________________
----If this post has helped you. Please take time to Rate it.
----If you've solved your problem, then please mark it as RESOLVED from Thread Tools.

-
Sep 28th, 2009, 01:00 AM
#9
Re: Read a Web Page Source / Attributes?
Ah, I see what you are getting at.
Have you had a chance to look at Mendhak's link yet? It pretty much sums it up. Since you are in control of both pages, you should know exactly what post data needs to be sent in the request, but if you are still not sure, get IEHttpHeaders, or something similar, and look directly at the Post Data that is being sent.
Gary
-
Oct 19th, 2009, 05:11 AM
#10
Thread Starter
Frenzied Member
Re: Read a Web Page Source / Attributes?
Its been a while since I've been working on this, but now I'm back at it.
I've looked at the Link and YES I've managed to READ the contents of the webpage, but haven't still figured out how to SUBMIT from Site1 to Site2.
I must fill a textbox called TextBox2 with a string
and then simulate a Button click, as in Submit
_____________________________________________________________________
----If this post has helped you. Please take time to Rate it.
----If you've solved your problem, then please mark it as RESOLVED from Thread Tools.

-
Oct 19th, 2009, 05:28 AM
#11
Re: Read a Web Page Source / Attributes?
Hey,
So what exactly aren't you sure on?
What information is your page expecting in the post? This will be in a particular format, and you need to match that information using the information you get in the textbox, and then create that data, in the same way as shown in the article:
string postData="userid="+strId;
postData += ("&username="+strName);
byte[] data = encoding.GetBytes(postData);
And then you simply post the data using the HttpWebRequest object.
Gary
-
Oct 20th, 2009, 11:28 AM
#12
Thread Starter
Frenzied Member
Re: Read a Web Page Source / Attributes?
Code:
string postData="userid="+strId;
postData += ("&username="+strName);
byte[] data = encoding.GetBytes(postData);
Thats not VB though is it.. C,C++ ?
Ok so how would I implement this to my scenario:
www.website1.com
a textbox in website1 needs to be filled with data.
a button in website1 then needs to be submitted
_____________________________________________________________________
----If this post has helped you. Please take time to Rate it.
----If you've solved your problem, then please mark it as RESOLVED from Thread Tools.

-
Oct 20th, 2009, 02:47 PM
#13
Re: Read a Web Page Source / Attributes?
Hey,
It's C#, but it is still possible in VB.
So let's say you have something called userid, that you need to submit to the website in the post data, with the value in something called textbox1, you would do something like the following:
Code:
Dim encoding As System.Text.ASCIIEncoding = New System.Text.ASCIIEncoding()
Dim postData As String = String.Format("userid={0}", TextBox1.Text)
Dim data As Byte() = encoding.GetBytes(postData)
Hope that helps!!
Gary
-
Oct 26th, 2009, 09:23 AM
#14
Thread Starter
Frenzied Member
Re: Read a Web Page Source / Attributes?
Thanks.. guys..
I've managed to fix this problem by adding the info in the URL and retrieving it with request.querystring, rather than adding it to a textbox etc...
So its all good.
_____________________________________________________________________
----If this post has helped you. Please take time to Rate it.
----If you've solved your problem, then please mark it as RESOLVED from Thread Tools.

Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|