Testing for connection to a website

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Alexnb

    Testing for connection to a website


    Okay, I already made this post, but it kinda got lost. So anyway I need to
    figure out how to test if the user is able to connect to a specific website.
    Last time I got pointed to the urllib2 page, but if I do urlopen() and and
    am not connected, the program stops. So I don't know if that was what you
    guys wanted me to do, but I don't think so, you guys are smarter than that.
    So, how can I test for connection to a website.
    --
    View this message in context: http://www.nabble.com/Testing-for-co...p18473382.html
    Sent from the Python - python-list mailing list archive at Nabble.com.

  • Jordan

    #2
    Re: Testing for connection to a website

    On Jul 15, 3:43 pm, Alexnb <alexnbr...@gma il.comwrote:
    Okay, I already made this post, but it kinda got lost. So anyway I need to
    figure out how to test if the user is able to connect to a specific website.
    Last time I got pointed to the urllib2 page, but if I do urlopen() and and
    am not connected, the program stops. So I don't know if that was what you
    guys wanted me to do, but I don't think so, you guys are smarter than that.
    So, how can I test for connection to a website.
    --
    View this message in context:http://www.nabble.com/Testing-for-co...te-tp18473382p...
    Sent from the Python - python-list mailing list archive at Nabble.com.
    Ping it? ~_^

    Comment

    • Grant Edwards

      #3
      Re: Testing for connection to a website

      On 2008-07-15, Alexnb <alexnbryan@gma il.comwrote:
      Okay, I already made this post, but it kinda got lost.
      No, it didn't get lost. Your question was answered and you
      didn't like the answer.
      So anyway I need to figure out how to test if the user is able
      to connect to a specific website. Last time I got pointed to
      the urllib2 page, but if I do urlopen() and and am not
      connected, the program stops.
      How long did you wait? Depending on what/how/where the network
      is broken, it make take a minute or two for the connection
      attempt to fail. You may not like it, but that's how TCP
      works. You're concerned with TCP connections, so you're going
      to have to live with it.
      So I don't know if that was what you guys wanted me to do,
      Yes it was what we advised you to do.
      but I don't think so, you guys are smarter than that. So, how
      can I test for connection to a website.
      Like we told you:

      1) Open a connection using urllib or urllib2.
      2) The attempt will either fail or succeed.
      3) Proceed accordingly.

      --
      Grant Edwards grante Yow! HUGH BEAUMONT died
      at in 1982!!
      visi.com

      Comment

      • Larry Bates

        #4
        Re: Testing for connection to a website

        Alexnb wrote:
        Okay, I already made this post, but it kinda got lost. So anyway I need to
        figure out how to test if the user is able to connect to a specific website.
        Last time I got pointed to the urllib2 page, but if I do urlopen() and and
        am not connected, the program stops. So I don't know if that was what you
        guys wanted me to do, but I don't think so, you guys are smarter than that.
        So, how can I test for connection to a website.
        You can test DNS resolution by doing this:

        import socket
        #
        # Check to make sure domain is legal and that I can resolve it to IP addr
        #
        try:
        ipaddr=socket.g ethostbyname(do main)
        except socket.gaierror :
        print "Internet connection or DNS error"

        For the "connect to a specific website" portion you just have to wait until it
        times out to determine failure.

        -Larry

        Comment

        Working...