0

I'm new and just learning the ropes with python programming and this was something I'm trying to do.

My internet is through a proxy server which requires authentication. How do I ping a website, for example 'www.google.com' using Python and check if it's successful?

P.S. my OS is windows

joaquin
  • 82,968
  • 29
  • 138
  • 152
user1637744
  • 13
  • 2
  • 5

1 Answers1

0
import urllib2
proxy_support = urllib2.ProxyHandler({'http':'http://login:password@my-proxy:port/'})
opener = urllib2.build_opener(proxy_support)
try:
    f = opener.open("http://google.com/")
    f.read(1)
    print "Success"
except Exception:
    print "Failed"
Maksym Polshcha
  • 18,030
  • 8
  • 52
  • 77