Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/319.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/linux/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 获取网页的当前版本_Python_Linux_Caching_Wget - Fatal编程技术网

Python 获取网页的当前版本

Python 获取网页的当前版本,python,linux,caching,wget,Python,Linux,Caching,Wget,如何获取Wget或Python中网页的当前版本?我需要完全关闭缓存 我正在努力编写代码,以便每秒钟下载一次。使用Python的urllib和Wget,我不会像在Chrome中那样获得当前文件。 我试过了 wget --cache=off --user-agent="Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1)" http://robocademy.com/courses/arduino/get_code/ 和带有urllib.urlclu

如何获取Wget或Python中网页的当前版本?我需要完全关闭缓存

我正在努力编写代码,以便每秒钟下载一次。使用Python的urllib和Wget,我不会像在Chrome中那样获得当前文件。 我试过了

wget --cache=off --user-agent="Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1)" http://robocademy.com/courses/arduino/get_code/
和带有urllib.urlclup的urllib

chrome中的响应标题:

Accept-Ranges:bytes
Age:0
Connection:keep-alive
Content-Encoding:gzip
Content-Length:449
Content-Type:text/plain
Date:Wed, 28 Nov 2012 23:20:24 GMT
Server:nginx
Vary:Accept-Encoding
Via:1.1 varnish
X-Varnish:400211059
Wget中的响应头

HTTP/1.1 200 OK
Server: nginx
Content-Type: text/plain
Keep-Alive: timeout=20
Vary: Accept-Encoding
Transfer-Encoding: chunked
Date: Wed, 28 Nov 2012 23:22:20 GMT
X-Varnish: 400216320 400212892
Age: 76
Via: 1.1 varnish
Connection: keep-alive
您可以尝试将
--无缓存
添加到wget。根据手册:

禁用服务器端缓存。在这种情况下,Wget将向远程服务器发送一个适当的指令(“Pragma:no cache”),以从远程服务获取文件,而不是返回缓存的版本。这对于在代理服务器上检索和刷新过期文档特别有用

默认情况下允许缓存

cache=off
应该放在
wgetrc
文件中


Python可以考虑这一点。

如何获取WGET或Python中的网页的当前版本?您正在获取Web页面的当前版本,因为服务器被配置为服务它。您是否有特定的原因要根据管理员的意图覆盖服务器的配置?这是我的站点。我需要最新版本,因为我正在为机器人制作一个网络控制器,需要尽快知道是否有新的命令要执行。你确定吗?问题是:如何获得Wget或Python中网页的当前版本?@timothylemans否,您问题的第4行表示您尝试了
--cache=off
,而不是
--no cache
;)我回答的第6行指出,
cache=off
应该进入WGETR文件。