473,394 Members | 1,663 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

how to get current weather information to my program

Hi all! I am new to python so what I am asking might be ambitious, but I want to know if there is a way to take information from the national weather service an use it as ambient tempertures to calculate heat trabsfer problems? Any help is greatly apperciated!
Dec 21 '14 #1

✓ answered by bvdet

Using the url suggested by RachelCook and a specific locale, the following will extract the high and low temperatures.
Expand|Select|Wrap|Line Numbers
  1. >>> from urllib import urlopen
  2. >>> from bs4 import BeautifulSoup
  3. >>> url = "http://weather.weatherbug.com/MN/Wahkon-weather.html?zcode=z6286&zip=56386"
  4. >>> soup = BeautifulSoup(urlopen(url).read())
  5. >>> soup.find(name="span", id="divHi").get_text()
  6. u'33\xb0F'
  7. >>> soup.find(name="span", id="divLo").get_text()
  8. u'28\xb0F'
  9. >>> 
  10.  

4 6104
There are lots of many websites now that providing a weather information. But one of the best source for that is http://weather.weatherbug.com/ you can visit that site to find what you need.
Dec 22 '14 #2
bvdet
2,851 Expert Mod 2GB
The website source can be read with the urllib module and parsed with Beautifulsoup or other suitable HTML parser.
Dec 22 '14 #3
bvdet
2,851 Expert Mod 2GB
Using the url suggested by RachelCook and a specific locale, the following will extract the high and low temperatures.
Expand|Select|Wrap|Line Numbers
  1. >>> from urllib import urlopen
  2. >>> from bs4 import BeautifulSoup
  3. >>> url = "http://weather.weatherbug.com/MN/Wahkon-weather.html?zcode=z6286&zip=56386"
  4. >>> soup = BeautifulSoup(urlopen(url).read())
  5. >>> soup.find(name="span", id="divHi").get_text()
  6. u'33\xb0F'
  7. >>> soup.find(name="span", id="divLo").get_text()
  8. u'28\xb0F'
  9. >>> 
  10.  
Dec 22 '14 #4
Thank you! That worked perfectly!
Dec 30 '14 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: JamesLomuscio | last post by:
To all who know C++, Im working on a prog that will be able to predict the weather, its too complicated to go into here, but I do need some help. I need to grab all of the information in the...
3
by: Bart | last post by:
I want to get the current username (or other information) about the user who is currently logged on in the windows 2000 domain. I thought about user.identity.name, but it returns an empty string....
5
by: James | last post by:
Hi, I working on an ASP .NET project, in this project I need to link my project with another program to retrieve data, how can I do that? I have access to source code of the other program where...
3
by: Neal | last post by:
VC++ VS 2003 I am currently finishing up a weather bug program that receives data from the weather.com weather feed, just need some finishing touches. The one issue I have run into seems to be...
14
by: YiMkiE | last post by:
I am a newbie of C and I need to do a program to get the current date information only, without the time. I have my code here: #include <stdio.h> #include <time.h> #include <string.h> int...
2
by: JayCally | last post by:
I want to add the current weather conditions in my area to my site. I've looked at some of the sites that will give you a generated script to add to your site but I don't like the way they look. I...
4
by: Jake G | last post by:
Hi all, I am trying to get a current weather conditions feed working. Yahoo provides a free feed @ http://weather.yahooapis.com/forecastrss?p=XXXXX where XXXXX is a valid US zip code e.g....
4
by: shaynenash | last post by:
I wrote this script to calculate if water restrictions were in place if it was hotter than 25deg C. It has turned out to be a pretty good weather widget that can be used elsewhere. This was initially...
10
by: farukcse | last post by:
Dear Sir, i need to add weather information in my web site. how can i do this using php? please try to inform to me. Regards, faruk chowdhury
1
by: Wei Jia | last post by:
1.Ajax. 2.http://j.maxmind.com/app/geoip.js for get client city. 3.Google weather API. IE test is passed!But others browser can't,why? <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.