-1

Well, I want to make a little console application that can get the weather and all its stats to show up in a little box, and I need to get this from a website, I'm thinking something like weather.com, and I need to do it in C++. I need it to simply grab some weather stats from the site and post them in a list on the console screen, in real time, or at least with a refresh button. Is this even possible or do I need to learn some java to do this?

pnuts
  • 58,317
  • 11
  • 87
  • 139
Mike44449
  • 1
  • 2
  • 3
  • http://stackoverflow.com/help/how-to-ask – shafeen Oct 08 '15 at 03:49
  • I don't have any source code by the way, I haven't started coding yet, I need to solve this problem before I begin. Let me sum this up in one sentence: How can I get data from a site in C++ in real time? – Mike44449 Oct 08 '15 at 03:51
  • 1
    Java and C++ are both Turing complete so you can do it in either. To get info from a website you need to use a socket - there are lots of choices for network libraries but if you want to make your own this may help: http://stackoverflow.com/questions/22077802/simple-c-example-of-doing-an-http-post-and-consuming-the-response It's probably simpler to use a networking library. To put the result in a box you need a windowing library like Qt or if you are on windows you can use Win32 but again there are lots of choices. – Jerry Jeremiah Oct 08 '15 at 03:53
  • 2
    You can use libcurl: http://curl.haxx.se/libcurl/ – Galik Oct 08 '15 at 03:53
  • 1
    to answer your question briefly, yes it is possible, but I'm not sure it will be an easy task if you are someone new to programming and/or new to c++ in general – shafeen Oct 08 '15 at 03:53
  • There are no socket (network communication) functions in the C++ Standard Library, so this boils down to a request for a library recommendation, which is off topic for Stack Overflow (though Galik's been generous ;-)). – Tony Delroy Oct 08 '15 at 04:03
  • he could use a JSON library right? I'm pretty new to c++ too but I remember doing a weather-forecast application with a json library and c# a few months ago. I used the API from openweathermap.com - you might want to check it out – benjamin Oct 08 '15 at 07:23

2 Answers2

1

Try feeds from news channel. Or popular Yahoo website API FOR WHETHER

Hey APIs are not in C or C++ specific(with some exception). You can directly download webpage where you can see whether report. Then press F12 & find under which HTML tag it lies. Then open that web page using socket API. THIS IS JUST SINGLE LINE CODE. for finding that tag you need string functions. Then copy & paste work. Also use threads to update time & date & obviously whether report.

  • this really doesn't answer the question – shafeen Oct 08 '15 at 03:56
  • Is there a way to use the Yahoo API for weather in C++, all I saw was objective C, please bear with me as I am still pretty new to this – Mike44449 Oct 08 '15 at 03:58
  • Hey APIs are not in C or C++ specific(with some exception). You can directly download webpage where you can see whether report. Then press F12 & find under which HTML tag it lies. Then open that web page using socket API. THIS IS JUST SINGLE LINE CODE. for finding that tag you need string functions. Then copy & paste work. Also use threads to update time & date & obviously whether report. – Vikas.Ghode Oct 08 '15 at 04:02
  • I'm not very good at C++ yet so pretty much all of what you said made little sense to me – Mike44449 Oct 08 '15 at 04:36
  • 1
    Do you want code ? Wait you will definitely get it. Let me find, its right on stackexchange – Vikas.Ghode Oct 08 '15 at 04:37
0

I have an application which has nothing to do with the weather.. however those customers are interested in seeing the weather in a box just like the person who asked for this... in worse case I will call a bash script curl wttr.in and translate the output to nice graphics from Oxygene icons at iconarchive.com. Who has a better solution?

Bart Mensfort
  • 995
  • 11
  • 21