[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.dotnet.framework.aspnet.webcontrols

WebResponse/WebRequest question/tutorial?

(Aaron)

1/7/2003 7:36:00 PM

Hello,

I am creating a web control that in the end result should show a webpage
based on user input.

I have a textbox(txtURL) and a button(btnSubmit). Upon btnSubmit_Click the
requested URL should load up in a literal(ltlMain).

I was wondering if there was a very detailed tutorial out there?

If not...

I have some of the code but I need to know how to connect it all together

WebRequest/WebResponse part of the code:

private String UrlReader(string sURL)
{
String sResult;
WebResponse objResponse;
WebRequest objRequest = System.Net.HttpRequest(sURL);
objResponse = objRequest.GetResponse();
using (StreamReader sr = new StreamReader(objResponse.GetResponseStream());
{
sResult = sr.ReadToEnd();
sr.Close();
}
return sResult;
}

Would I do this for getting the URL --

{
sURL = txtURL.Text
}

and to bind the request to the literal
{
ltlMain.Text = URLReader() -- want would go there???
}

TIA

Aaron


4 Answers

(Scott Mitchell [MVP])

1/8/2003 3:54:00 AM

0

Aaron, if all you're doing is screen scraping, you may want to consider
using the WebClient class.

See:

Screen Scrapes in ASP.NET
http://www.4guysfromrolla.com/webtech/0706...

hth


--


Scott Mitchell [MVP]
http://www.4GuysFro...
http://www.ASPMessag...
http://www.A...

* When you think ASP, think 4GuysFromRolla.com!



aaron wrote:
> Hello,
>
> I am creating a web control that in the end result should show a webpage
> based on user input.
>
> I have a textbox(txtURL) and a button(btnSubmit). Upon btnSubmit_Click the
> requested URL should load up in a literal(ltlMain).
>
> I was wondering if there was a very detailed tutorial out there?
>
> If not...
>
> I have some of the code but I need to know how to connect it all together
>
> WebRequest/WebResponse part of the code:
>
> private String UrlReader(string sURL)
> {
> String sResult;
> WebResponse objResponse;
> WebRequest objRequest = System.Net.HttpRequest(sURL);
> objResponse = objRequest.GetResponse();
> using (StreamReader sr = new StreamReader(objResponse.GetResponseStream());
> {
> sResult = sr.ReadToEnd();
> sr.Close();
> }
> return sResult;
> }
>
> Would I do this for getting the URL --
>
> {
> sURL = txtURL.Text
> }
>
> and to bind the request to the literal
> {
> ltlMain.Text = URLReader() -- want would go there???
> }

(Aaron)

1/8/2003 5:23:00 AM

0

Scott,

I what to screen key information; email address and web address from the
screen that are embedded. As well I need to have the ability to type in the
URL natural and then scrape the information. If you know of any tutorials
that don't need 3th party controls on this; it would be greatly appreciated.

thanks for your link.

Aaron


(Scott Mitchell [MVP])

1/8/2003 5:44:00 AM

0

aaron wrote:
> Scott,
>
> I what to screen key information; email address and web address from the
> screen that are embedded. As well I need to have the ability to type in the
> URL natural and then scrape the information. If you know of any tutorials
> that don't need 3th party controls on this; it would be greatly appreciated.

You'll have to use regular expressions to extract the content you want
from the HTML you grab. See:


Common Applications of Regular Expressions, Part 2 - Extracting
Specific Sections From An HTML Page
http://www.4guysfromrolla.com/webtech/120400...

For a more basic primer on Regular Expressions see:

An Introduction to Regular Expression with VBScript
http://www.4guysfromrolla.com/webtech/0901...

(Yes, these articles are ASP articles and hence use VBScript's regex
syntax, but the difference between VB.NET's regular expresison syntax is
trivial, see:

How do I use regular expressions from an ASP.NET Web page?
http://www.aspfaqs.com/aspfaqs/ShowFAQ.asp...
)

Happy Programming!

--


Scott Mitchell [MVP]
http://www.4GuysFro...
http://www.ASPMessag...
http://www.A...

* When you think ASP, think 4GuysFromRolla.com!

(Aaron)

1/8/2003 5:59:00 AM

0

Scott,

Thanks for the great links.

I will work on this.

Aaron

"Scott Mitchell [MVP]" <smitchell@internet.com> wrote in message
news:A0OS9.3712$YH1.2056@newssvr19.news.prodigy.com...
> aaron wrote:
> > Scott,
> >
> > I what to screen key information; email address and web address from the
> > screen that are embedded. As well I need to have the ability to type in
the
> > URL natural and then scrape the information. If you know of any
tutorials
> > that don't need 3th party controls on this; it would be greatly
appreciated.
>
> You'll have to use regular expressions to extract the content you want
> from the HTML you grab. See:
>
>
> Common Applications of Regular Expressions, Part 2 - Extracting
> Specific Sections From An HTML Page
> http://www.4guysfromrolla.com/webtech/120400...
>
> For a more basic primer on Regular Expressions see:
>
> An Introduction to Regular Expression with VBScript
> http://www.4guysfromrolla.com/webtech/0901...
>
> (Yes, these articles are ASP articles and hence use VBScript's regex
> syntax, but the difference between VB.NET's regular expresison syntax is
> trivial, see:
>
> How do I use regular expressions from an ASP.NET Web page?
> http://www.aspfaqs.com/aspfaqs/ShowFAQ.asp...
> )
>
> Happy Programming!
>
> --
>
>
> Scott Mitchell [MVP]
> http://www.4GuysFro...
> http://www.ASPMessag...
> http://www.A...
>
> * When you think ASP, think 4GuysFromRolla.com!
>