File tree Expand file tree Collapse file tree 1 file changed +25
-0
lines changed
Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Original file line number Diff line number Diff line change 1+ """
2+ Get Atomic Time from Internet Clock - This program will get
3+ the true atomic time from an atomic time clock on the Internet.
4+ Use any one of the atomic clocks returned by a simple Google search.
5+ """
6+
7+ import re
8+ from urllib2 import urlopen
9+
10+
11+ def main ():
12+ url = 'http://time.is/just'
13+ content = urlopen (url ).read ()
14+ pattern = re .compile ('<div id="twd">(.*)<span id="ampm" style="font-size:21px;line-height:21px">(AM|PM)</span></div>' )
15+
16+ find_match = re .search (pattern , content )
17+
18+ location_pat = re .compile ('<h1 id="pL" class="w90 tr"><a href="/facts/\w+">(.*)</a></h1>' )
19+ location_match = re .search (location_pat , content )
20+
21+ print 'The time in %s is %s %s' % \
22+ (location_match .group (1 ), find_match .group (1 ), find_match .group (2 ))
23+
24+ if __name__ == '__main__' :
25+ main ()
You can’t perform that action at this time.
0 commit comments