Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit f827100

Browse files
committed
Blacks
Weather Report user import re
1 parent a5455ab commit f827100

File tree

1 file changed

+67
-0
lines changed

1 file changed

+67
-0
lines changed

bc.py

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
#-------------------------------------------------------------------------------
2+
# Name: module1
3+
# Purpose:
4+
#
5+
# Author: casey.jenkins
6+
#
7+
# Created: 26/10/2012
8+
# Copyright: (c) casey.jenkins 2012
9+
# Licence: <your licence>
10+
#-------------------------------------------------------------------------------
11+
#!/usr/bin/env python
12+
13+
#!/usr/bin/python
14+
#print "Content-Type: text/plain\n\n"
15+
import urllib, re, sys
16+
import cgi
17+
18+
#LOCO = sys.argv[1].upper()
19+
20+
url = "http://api.wunderground.com/weatherstation/WXCurrentObXML.asp?ID=MGRAI1"
21+
22+
url_1 = "http://api.wunderground.com/weatherstation/WXCurrentObXML.asp?ID=MAR795"
23+
24+
url_2 = "http://www.pacificorp.com/es/hydro/hl/wr/br/bgd.html"
25+
26+
# Create the regex and use multiline
27+
28+
webpage = urllib.urlopen(url).read()
29+
30+
webpage1 = urllib.urlopen(url_1).read()
31+
32+
webpage2 = urllib.urlopen(url_2).read()
33+
34+
match = re.search("<city>([^<]*)</city>", webpage)
35+
loc = match.group(1)
36+
37+
match = re.search("<observation_time>([^<]*)</observation_time>", webpage)
38+
time = match.group(1)
39+
40+
match = re.search("<windchill_string>([^<]*)</windchill_string>", webpage)
41+
wind_chill = match.group(1)
42+
43+
match = re.search("<state>([^<]*)</state>", webpage)
44+
state = match.group(1)
45+
46+
match = re.search("<temperature_string>([^<]*)</temperature_string>", webpage)
47+
temp = match.group(1)
48+
49+
match = re.search("<wind_string>([^<]*)</wind_string>", webpage)
50+
wind = match.group(1)
51+
52+
match = re.search("<relative_humidity>([^<]*)</relative_humidity>", webpage)
53+
rh = match.group(1)
54+
55+
match = re.search("<precip_1hr_in>([^<]*)</precip_1hr_in>", webpage1)
56+
precip = match.group(1)
57+
58+
#Water Level
59+
match = re.search("</td><td>([^<]*)</td><td></td></tr></table>", webpage2)
60+
level = match.group(1)
61+
62+
print " Temperature", temp
63+
print " Wind",wind
64+
print " RH",rh,"%"
65+
print " Precipitation", precip, "in"
66+
print " Water Level", level, "CFS"
67+
print " ",time

0 commit comments

Comments
 (0)