import urllib3
email='tweetable@python.com'
resp=urllib3.PoolManager().urlopen('GET', 'https://haveibeenpwned.com/api/v2/breachedaccount/{}'.format(email),
headers={'user-agent': 'Pwnage-Checker-For-Django'})
print('Breached' if resp.data else 'Secure')
import urllib3,json
resp=urllib3.PoolManager().request('GET', 'https://maps.googleapis.com/maps/api/geocode/json?address='+'madhapur,hyderabad')
json_resp=json.loads(resp.data)['results']
print(json_resp[0]['geometry']['location'] if json_resp['status'] == 'OK' else [])
https://maps.googleapis.com/maps/api/geocode/json?address=madhapur,hyderabad
import urllib3
def get_quote_of_the_day():
http=urllib3.PoolManager()
resp=http.request('GET', 'https://quotes.rest/qod')
return resp['contents']['quotes'][0]['quote']
Fetch quote of the day from the rest API provided by theysaidso.com.
http://code.activestate.com/recipes/117211-simple-very-sntp-client/
s.AF_INET is 2 s.SOCK_DGRAM is 2
import socket as s,struct,time
def ntp(url):
c=s.socket(2,2)
d=b'\x1b'+47*b'\0'
c.sendto(d,(url,123))
d,address=c.recvfrom(1024)
if d:
t=struct.unpack('!12I',d)[10]
t -= 2208988800
return time.ctime(t),t