Python httplib2 Handling Exceptions

后端 未结 2 906
名媛妹妹
名媛妹妹 2021-02-06 15:13

I have this very simple code to check if a site is up or down.

import httplib2
h = httplib2.Http()
response, content = h.request(\"http://www.folksdhhkjd.com\")         


        
2条回答
  •  梦谈多话
    2021-02-06 15:28

    h = httplib2.Http('.cache')   
    

    Caches the stuff it retrieves in a directory called .cache so if you do the same request twice it might not have to actually get everything twice; a file starting with a dot is hidden in POSIX filesystems (like on Linux).

    h = httplib2.Http()
    

    Doesn't cache it's results, so you have to get everything requested every time.

提交回复
热议问题