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

Skip to content

Commit 96793d7

Browse files
committed
Black Canyon cgi and NetCondom
1 parent 6edfca3 commit 96793d7

File tree

2 files changed

+67
-0
lines changed

2 files changed

+67
-0
lines changed

NetCondom.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import socket
2+
3+
ip = raw_input("IP: ")
4+
port = int(raw_input("Port: "))
5+
6+
try:
7+
s = socket.socket()
8+
s.settimeout(5)
9+
s.connect((ip,port))
10+
s.send("HEAD / HTTP/1.0 \r\n\r\n")
11+
12+
result = s.recv(1024)
13+
s.close()
14+
print str(result)
15+
16+
except Exception, e:
17+
print str (e)
18+
import socket

bc.cgi

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
#!/usr/bin/python
2+
print "Content-Type: text/plain\n\n"
3+
import urllib, re, sys
4+
import cgi
5+
6+
url = "http://api.wunderground.com/weatherstation/WXCurrentObXML.asp?ID=MGRAI1"
7+
8+
url_1 = "http://api.wunderground.com/weatherstation/WXCurrentObXML.asp?ID=MAR795"
9+
10+
# Create the regex and use multiline
11+
12+
webpage = urllib.urlopen(url).read()
13+
14+
webpage1 = urllib.urlopen(url_1).read()
15+
16+
match = re.search("<city>([^<]*)</city>", webpage)
17+
loc = match.group(1)
18+
19+
match = re.search("<observation_time>([^<]*)</observation_time>", webpage)
20+
time = match.group(1)
21+
22+
match = re.search("<windchill_string>([^<]*)</windchill_string>", webpage)
23+
wind_chill = match.group(1)
24+
25+
match = re.search("<state>([^<]*)</state>", webpage)
26+
state = match.group(1)
27+
28+
match = re.search("<temperature_string>([^<]*)</temperature_string>", webpage)
29+
temp = match.group(1)
30+
31+
match = re.search("<wind_string>([^<]*)</wind_string>", webpage)
32+
wind = match.group(1)
33+
34+
match = re.search("<relative_humidity>([^<]*)</relative_humidity>", webpage)
35+
rh = match.group(1)
36+
37+
match = re.search("<elevation>([^<]*)</elevation>", webpage)
38+
ele = match.group(1)
39+
40+
match = re.search("<precip_today_string>([^<]*)</precip_today_string>", webpage)
41+
precip = match.group(1)
42+
43+
print " Black Canyon Weather Report"
44+
print " Elevation", ele
45+
print " Temperature", temp
46+
print " Wind",wind
47+
print " Precipitation Today", precip
48+
print " RH",rh,"%"
49+
print " ",time

0 commit comments

Comments
 (0)