Python urllib cache

前端 未结 2 1464
春和景丽
春和景丽 2021-01-28 16:43

I\'m writing a script in Python that should determine if it has internet access.

import urllib

CHECK_PAGE     = \"http://64.37.51.146/check.txt\"
CHECK_VALUE            


        
2条回答
  •  误落风尘
    2021-01-28 17:15

    Call urllib.urlcleanup() before each call of urllib.urlopen() will solve the problem. Actually, urllib.urlopen will call urlretrive() function which creates a cache to hold data, and urlcleanup() will remove it.

提交回复
热议问题