954,514 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

is this possible?

HI,


would it be possible to print only the TEXT forcast of this website into a textbox....no pictures no nothing just the text. if so how?

tayspen
<Insert title here>
Team Colleague
1,622 posts since Jul 2005
Reputation Points: 84
Solved Threads: 99
 

copy and paste into notepad? ;)

campkev
Posting Pro in Training
484 posts since Jul 2005
Reputation Points: 14
Solved Threads: 19
 

ha ha.... come on now. i want to do it via C#. so any SERIOUS ideas?

tayspen
<Insert title here>
Team Colleague
1,622 posts since Jul 2005
Reputation Points: 84
Solved Threads: 99
 

I was just kidding because I'm not 100% sure what you meant. You want your program to pull data from a webpage and print it out, is that right?

campkev
Posting Pro in Training
484 posts since Jul 2005
Reputation Points: 14
Solved Threads: 19
 
I was just kidding because I'm not 100% sure what you meant. You want your program to pull data from a webpage and print it out, is that right?

Lol yea i knew you were kidding. ok this is what i want it to do. Just in the link above in earlier post as you can see there is 36 hrs worth of forcast right there in text. I want to open that info into a text box. (juast text no pics) thats as clear as i can get.Possible?

tayspen
<Insert title here>
Team Colleague
1,622 posts since Jul 2005
Reputation Points: 84
Solved Threads: 99
 

and you want to do this from a windows app right? I will see what I can figure out on monday.

campkev
Posting Pro in Training
484 posts since Jul 2005
Reputation Points: 14
Solved Threads: 19
 
and you want to do this from a windows app right? I will see what I can figure out on monday.

ok, thanks alot and yes a windows app.

tayspen
<Insert title here>
Team Colleague
1,622 posts since Jul 2005
Reputation Points: 84
Solved Threads: 99
 

possible but prly not the best way to add weather to an app. i would suggest retreiveing an rss feed from a site like http://www.rssweather.com .

because to get weather from that site yo would need to sent a WebRequest for that website then parse the html for the entire page, and remove all the extra html tags. making extra work thats not needed, but i will include source on a htmlGet and htmlPost so you have an idea on how to do this anyways

this code gets the html from a site

using System.Net;


		private string GetHTML(string strURL)
		{
			WebResponse objResponse = null;
			String strHTML;

			try
			{
				Uri objUri = new Uri(strURL);
				WebRequest objRequest = WebRequest.Create(objUri);
				
				objResponse = objRequest.GetResponse();				
				Stream objStream = objResponse.GetResponseStream();;

				Encoding encode = System.Text.Encoding.UTF8;
				StreamReader objReader = new StreamReader(objStream, encode);

				strHTML = objReader.ReadToEnd();

			}
			catch(Exception ex) 
			{
				return ex.ToString();

			}
			finally 
			{	
				objResponse.Close();

			}

			return strHTML;

		}

		private string Post(string strURL, string strPostData)
		{
			WebResponse objResponse = null;
			string strResult = null;

			try
			{
				Uri objUri = new Uri(strURL);
				WebRequest objRequest = WebRequest.Create(objUri);

				objRequest.Method = "POST";
				objRequest.ContentType = "application/x-www-form-urlencoded";

				StringBuilder UrlEncoded = new StringBuilder();
				Char[] reserved = {'?', '=', '&'};
				Byte[] SomeBytes = null;

				if(strPostData != null)
				{
					int i = 0, j;
					while(i< strPostData.Length)
					{
						j = strPostData.IndexOfAny(reserved, i);
						if(j == -1)
						{
							UrlEncoded.Append(HttpUtility.UrlEncode(strPostData.Substring(i, strPostData.Length - i)));
							break;
						}
						UrlEncoded.Append(HttpUtility.UrlEncode(strPostData.Substring(i, j-i)));
						UrlEncoded.Append(HttpUtility.UrlEncode(strPostData.Substring(j, 1)));
						i = j+1;
						
					}


					SomeBytes = Encoding.UTF8.GetBytes(UrlEncoded.ToString());
					objRequest.ContentLength = SomeBytes.Length;


					Stream objStream = objRequest.GetRequestStream();

					objStream.Write(SomeBytes, 0, SomeBytes.Length);
					objStream.Close();
				}
				else
				{
					objRequest.ContentLength = 0;
				}


				objResponse = objRequest.GetResponse();

				Stream objReceiveStream = objResponse.GetResponseStream();

				Encoding encode = System.Text.Encoding.UTF8;
				StreamReader objReader = new StreamReader(objReceiveStream, encode);

				strResult = objReader.ReadToEnd();

				
				
			}
			catch(Exception ex)
			{
				return ex.ToString();
			}
			finally
			{
				if(objResponse != null)
				{
					objResponse.Close();
				}
			}
			
			return strResult;

		}
plazmo
Posting Whiz in Training
207 posts since Aug 2005
Reputation Points: 23
Solved Threads: 16
 

possible but prly not the best way to add weather to an app. i would suggest retreiveing an rss feed from a site like http://www.rssweather.com .

because to get weather from that site yo would need to sent a WebRequest for that website then parse the html for the entire page, and remove all the extra html tags. making extra work thats not needed, but i will include source on a htmlGet and htmlPost so you have an idea on how to do this anyways

using System.Net;


		private string GetHTML(string strURL)
		{
			WebResponse objResponse = null;
			String strHTML;

			try
			{
				Uri objUri = new Uri(strURL);
				WebRequest objRequest = WebRequest.Create(objUri);
				
				objResponse = objRequest.GetResponse();				
				Stream objStream = objResponse.GetResponseStream();;

				Encoding encode = System.Text.Encoding.UTF8;
				StreamReader objReader = new StreamReader(objStream, encode);

				strHTML = objReader.ReadToEnd();

			}
			catch(Exception ex) 
			{
				return ex.ToString();

			}
			finally 
			{	
				objResponse.Close();

			}

			return strHTML;

		}

		private string Post(string strURL, string strPostData)
		{
			WebResponse objResponse = null;
			string strResult = null;

			try
			{
				Uri objUri = new Uri(strURL);
				WebRequest objRequest = WebRequest.Create(objUri);

				objRequest.Method = "POST";
				objRequest.ContentType = "application/x-www-form-urlencoded";

				StringBuilder UrlEncoded = new StringBuilder();
				Char[] reserved = {'?', '=', '&'};
				Byte[] SomeBytes = null;

				if(strPostData != null)
				{
					int i = 0, j;
					while(i< strPostData.Length)
					{
						j = strPostData.IndexOfAny(reserved, i);
						if(j == -1)
						{
							UrlEncoded.Append(HttpUtility.UrlEncode(strPostData.Substring(i, strPostData.Length - i)));
							break;
						}
						UrlEncoded.Append(HttpUtility.UrlEncode(strPostData.Substring(i, j-i)));
						UrlEncoded.Append(HttpUtility.UrlEncode(strPostData.Substring(j, 1)));
						i = j+1;
						
					}


					SomeBytes = Encoding.UTF8.GetBytes(UrlEncoded.ToString());
					objRequest.ContentLength = SomeBytes.Length;


					Stream objStream = objRequest.GetRequestStream();

					objStream.Write(SomeBytes, 0, SomeBytes.Length);
					objStream.Close();
				}
				else
				{
					objRequest.ContentLength = 0;
				}


				objResponse = objRequest.GetResponse();

				Stream objReceiveStream = objResponse.GetResponseStream();

				Encoding encode = System.Text.Encoding.UTF8;
				StreamReader objReader = new StreamReader(objReceiveStream, encode);

				strResult = objReader.ReadToEnd();

				
				
			}
			catch(Exception ex)
			{
				return ex.ToString();
			}
			finally
			{
				if(objResponse != null)
				{
					objResponse.Close();
				}
			}
			
			return strResult;

		}


hey thanks man. i thought rss would be the better option. but dont no how to read those. is it easy. Sample code? but thatnks for this im gonna look at it now :)

tayspen
<Insert title here>
Team Colleague
1,622 posts since Jul 2005
Reputation Points: 84
Solved Threads: 99
 

i dont know yet but thats something i want to learn, so after i learn if you havent figured it out yet i will post some code. post your code when you figure it out to please

plazmo
Posting Whiz in Training
207 posts since Aug 2005
Reputation Points: 23
Solved Threads: 16
 

will do, thanks for your help.

tayspen
<Insert title here>
Team Colleague
1,622 posts since Jul 2005
Reputation Points: 84
Solved Threads: 99
 

well i know one way to use rss feed if you know how to work with datasets. its very simple, but i dont know if this is the best way to do this. if someone could suggest a better way i could try.

DataSet ds = new DataSet("RSS Feed");
			ds.ReadXml(@"http://securityfocus.com/rss/news.xml");
			dataGrid1.DataSource = ds;
			dataGrid1.DataMember = "Channel";
			dataGrid1.CaptionText = "RSS Feed";
plazmo
Posting Whiz in Training
207 posts since Aug 2005
Reputation Points: 23
Solved Threads: 16
 

well i know one way to use rss feed if you know how to work with datasets. its very simple, but i dont know if this is the best way to do this. if someone could suggest a better way i could try.

DataSet ds = new DataSet("RSS Feed");
			ds.ReadXml(@"http://securityfocus.com/rss/news.xml");
			dataGrid1.DataSource = ds;
			dataGrid1.DataMember = "Channel";
			dataGrid1.CaptionText = "RSS Feed";


ok, wait so aan rss feed is an xml file right? if so would be parse that the show just what we want in a text box? thats what i need to do.... is this possile do u know how?

im a bit confused on how this works...i will research rss files....

tayspen
<Insert title here>
Team Colleague
1,622 posts since Jul 2005
Reputation Points: 84
Solved Threads: 99
 

perhaps this will help

http://www.codeproject.com/csharp/RssReader.asp

i am going to take a look at it


EDIT: ising this libary and example i successfullf pulled the headline news from google.(just title)

http://www.example-code.com/csharp/googleRssHeadlines.asp

tayspen
<Insert title here>
Team Colleague
1,622 posts since Jul 2005
Reputation Points: 84
Solved Threads: 99
 

a rss is only a xml document based on a strict scheme

plazmo
Posting Whiz in Training
207 posts since Aug 2005
Reputation Points: 23
Solved Threads: 16
 
a rss is only a xml document based on a strict scheme

ok.

tayspen
<Insert title here>
Team Colleague
1,622 posts since Jul 2005
Reputation Points: 84
Solved Threads: 99
 

have you gotten anywhre with this, i made up a program if you want to see it

plazmo
Posting Whiz in Training
207 posts since Aug 2005
Reputation Points: 23
Solved Threads: 16
 

sure i would love to see it. i have been able to retrive the headlines. thats about it though havnt really dug in. yea if you wouldnt mind posting it id like to see

tayspen
<Insert title here>
Team Colleague
1,622 posts since Jul 2005
Reputation Points: 84
Solved Threads: 99
 

http://anti-intelligence.com/files/rssReader.zip

i made this up sorta quick so i hope you understand it

but i displayed it in both a treeview and datagrid

the only problem is googles rss displays html in part of the rss so its hard to read without removing the html

plazmo
Posting Whiz in Training
207 posts since Aug 2005
Reputation Points: 23
Solved Threads: 16
 

Nice. Yea i understand it. I want to extend it so it gets the whole article. then can save that to a text file. Looks good thx for the ex.


EDIT: For some reson it doesnt seem to be reading google correctly.

tayspen
<Insert title here>
Team Colleague
1,622 posts since Jul 2005
Reputation Points: 84
Solved Threads: 99
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You