2015-02-06 29 views

回答

1

在Python文檔中,據說filehandle = urllib.urlopen(some_url, proxies={})將導致系統不向我們提供任何代理,甚至是系統的代理。

處理urlopen()非常簡單。 filehandle支持read()獲取數據的方法。然後打開一個文件並將數據寫入它。

filehandle成功通話後充滿數據。

fi=open(some_file,mode) 
fi.write(filehandle.read()) 
fi.close() 
0

只是想我會發佈一個完整的例子。

#!/bin/python 

import urllib 

filehandle = urllib.urlopen("https://docs.python.org/2/library/urllib.html", proxies={}) 
fi=open("read_this.html", "w") 
fi.write(filehandle.read()) 
fi.close()