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>
1,622 posts since Jul 2005
Reputation Points: 84
Solved Threads: 99
ha ha.... come on now. i want to do it via C#. so any SERIOUS ideas?
tayspen
<Insert title here>
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?
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>
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.
ok, thanks alot and yes a windows app.
tayspen
<Insert title here>
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
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>
1,622 posts since Jul 2005
Reputation Points: 84
Solved Threads: 99
will do, thanks for your help.
tayspen
<Insert title here>
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";
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>
1,622 posts since Jul 2005
Reputation Points: 84
Solved Threads: 99
tayspen
<Insert title here>
1,622 posts since Jul 2005
Reputation Points: 84
Solved Threads: 99
a rss is only a xml document based on a strict scheme
ok.
tayspen
<Insert title here>
1,622 posts since Jul 2005
Reputation Points: 84
Solved Threads: 99
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>
1,622 posts since Jul 2005
Reputation Points: 84
Solved Threads: 99
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>
1,622 posts since Jul 2005
Reputation Points: 84
Solved Threads: 99