get the stream writer of the webbrowser control
-
Hi, How can I get the 'pointer' of the stream writer the webbrowser control uses to navigate to websites? Thanks in advance!
I *think* the DocumentStream[^] property is what you're looking for.
:bob: Kristian Sixhoej "You can always become better." - Tiger Woods
-
I *think* the DocumentStream[^] property is what you're looking for.
:bob: Kristian Sixhoej "You can always become better." - Tiger Woods
-
I thought that's the one i needed too. But where would i put the url to navigate to another url with it?
Yustme wrote:
But where would i put the url to navigate to another url with it?
I'm not sure if I understand this, but to navigate to another URL, you call the
Navigate
method of the webbrowser control, passing in the URL to navigate to, like so:webBrowser1.Navigate("http://codeproject.com");
:bob: Kristian Sixhoej "You can always become better." - Tiger Woods
-
Yustme wrote:
But where would i put the url to navigate to another url with it?
I'm not sure if I understand this, but to navigate to another URL, you call the
Navigate
method of the webbrowser control, passing in the URL to navigate to, like so:webBrowser1.Navigate("http://codeproject.com");
:bob: Kristian Sixhoej "You can always become better." - Tiger Woods
Ideally would be using the response class. Its much faster. But i can't log in on a website with it. I got a multithreaded application. When entering the event: WebBrowserDocumentCompletedEventArgs , another thread already navigated to another page. So i'll lose the last page where the webcontrol navigated to. Making the threads sleep a few seconds, doesn't help either. All i'm trying to get is the page content in html format.
-
Ideally would be using the response class. Its much faster. But i can't log in on a website with it. I got a multithreaded application. When entering the event: WebBrowserDocumentCompletedEventArgs , another thread already navigated to another page. So i'll lose the last page where the webcontrol navigated to. Making the threads sleep a few seconds, doesn't help either. All i'm trying to get is the page content in html format.
Yustme wrote:
All i'm trying to get is the page content in html format.
By that, do you mean getting the HTML behind the page? If so, the DocumentText[^] property is what you need. It also allows you to modify the HTML contents, but I'm not sure if it's gonna work with what you're trying to accomplish:
Yustme wrote:
But i can't log in on a website with it.
You may wanna have a look at the HtmlDocument[^] class.
:bob: Kristian Sixhoej "You can always become better." - Tiger Woods
-
Yustme wrote:
All i'm trying to get is the page content in html format.
By that, do you mean getting the HTML behind the page? If so, the DocumentText[^] property is what you need. It also allows you to modify the HTML contents, but I'm not sure if it's gonna work with what you're trying to accomplish:
Yustme wrote:
But i can't log in on a website with it.
You may wanna have a look at the HtmlDocument[^] class.
:bob: Kristian Sixhoej "You can always become better." - Tiger Woods
-
Yes i can get the html code from the page. But i need to navigate to it first. And there are a lot of pages to walk through.
What exactly are you trying to create? Perhaps the WebBrowser control isn't the ideal solution for this, but that depends on what you're trying to do.
:bob: Kristian Sixhoej "You can always become better." - Tiger Woods
-
What exactly are you trying to create? Perhaps the WebBrowser control isn't the ideal solution for this, but that depends on what you're trying to do.
:bob: Kristian Sixhoej "You can always become better." - Tiger Woods
Getting html code of a topic in a vbulletin forum. If you're not logged in, you're not allowed to view the topic. I can't log in with the response class. This was my try:
private string login(string url, string username, string password)
{
string values = "vb_login_username={0}&vb_login_password={1}";
values += "&securitytoken=guest&cookieuser=checked&do=login";values = string.Format(values, username, password); HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url); req.Method = "POST"; req.ContentType = "application/x-www-form-urlencoded"; req.ContentLength = values.Length; req.Timeout = 10000; CookieContainer a = new CookieContainer(); req.CookieContainer = a; System.Net.ServicePointManager.Expect100Continue = false; // prevents 417 error using (StreamWriter writer = new StreamWriter(req.GetRequestStream(), System.Text.Encoding.ASCII)) { writer.Write(values, 0, values.Length); } this.response = (HttpWebResponse)req.GetResponse(); StringBuilder output = new StringBuilder(); foreach (var cookie in response.Cookies) { output.Append(cookie.ToString()); output.Append(";"); } return output.ToString(); }
</pre>
-
Getting html code of a topic in a vbulletin forum. If you're not logged in, you're not allowed to view the topic. I can't log in with the response class. This was my try:
private string login(string url, string username, string password)
{
string values = "vb_login_username={0}&vb_login_password={1}";
values += "&securitytoken=guest&cookieuser=checked&do=login";values = string.Format(values, username, password); HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url); req.Method = "POST"; req.ContentType = "application/x-www-form-urlencoded"; req.ContentLength = values.Length; req.Timeout = 10000; CookieContainer a = new CookieContainer(); req.CookieContainer = a; System.Net.ServicePointManager.Expect100Continue = false; // prevents 417 error using (StreamWriter writer = new StreamWriter(req.GetRequestStream(), System.Text.Encoding.ASCII)) { writer.Write(values, 0, values.Length); } this.response = (HttpWebResponse)req.GetResponse(); StringBuilder output = new StringBuilder(); foreach (var cookie in response.Cookies) { output.Append(cookie.ToString()); output.Append(";"); } return output.ToString(); }
</pre>
I don't know why your login request doesn't work, but another approach to the problem could be: 1. Navigate to the URL using the WebBrowser control. 2. If a login form is displayed, use HtmlDocument to fill in the values (username + password) and "click" the Login button. Depending on how the site is coded, the browser should automatically navigate to the requested forum topic. 3. Grab the HTML by using the DocumentStream property. Although this definitely isn't the most ideal solution if you have to "visit" several sites. WebRequest is probably the way to go if that's the case. Have you got any idea as to why your login request fails? Does the site display an error message?
:bob: Kristian Sixhoej "You can always become better." - Tiger Woods
-
I don't know why your login request doesn't work, but another approach to the problem could be: 1. Navigate to the URL using the WebBrowser control. 2. If a login form is displayed, use HtmlDocument to fill in the values (username + password) and "click" the Login button. Depending on how the site is coded, the browser should automatically navigate to the requested forum topic. 3. Grab the HTML by using the DocumentStream property. Although this definitely isn't the most ideal solution if you have to "visit" several sites. WebRequest is probably the way to go if that's the case. Have you got any idea as to why your login request fails? Does the site display an error message?
:bob: Kristian Sixhoej "You can always become better." - Tiger Woods
Im already filling the form's manually in the webbrowser control. My idea why the login fails is because of the 'salt' it adds after the password. And it gets the salt from the DB. If i could fill in the forms programmatically with webresponse and request, would be great. This way, i dont have to load anything, which takes a lot of time.