Python urllib cache

前端 未结 2 1439
春和景丽
春和景丽 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.

    0 讨论(0)
  • 2021-01-28 17:25

    You want

    page = urllib.urlopen(CHECK_PAGE, proxies={})
    

    Remove the

    urllib.getproxies = lambda x = None: {}
    

    line.

    0 讨论(0)
提交回复
热议问题