Guest User

Untitled

a guest
Apr 25th, 2018
491
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.77 KB | None | 0 0
  1. import time
  2. from geopy.geocoders import GoogleV3
  3. import os
  4.  
  5. def set_proxy():
  6. proxy_addr = 'http://{user}:{passwd}@{address}:{port}'.format(
  7. user='usuario', passwd='senha',
  8. address='IP', port=int('PORTA'))
  9. os.environ['http_proxy'] = proxy_addr
  10. os.environ['https_proxy'] = proxy_addr
  11.  
  12. def unset_proxy():
  13. os.environ.pop('http_proxy')
  14. os.environ.pop('https_proxy')
  15.  
  16. set_proxy()
  17.  
  18. geo_keys = ['AIzaSyBXkATWIrQyNX6T-VRa2gRmC9dJRoqzss0'] # API Google
  19. geolocator = GoogleV3(api_key=geo_keys )
  20.  
  21. for index, row in df.iterrows():
  22. location = geolocator.geocode(row['NO_LOGRADOURO'])
  23. time.sleep(2)
  24. lat=location.latitude
  25. lon=location.longitude
  26. timeout=10)
  27. address = location.address
  28. unset_proxy()
  29. print(str(lat) + ', ' + str(lon))
Add Comment
Please, Sign In to add comment