# -*- coding:gb2312 -*-
import urllib.request
source_stram = urllib.request.urlopen("http://www.12306.cn/mormhweb/kyfw/")
#save_path="D:\\baiDuYun\\百度云\\Code\\DotNet\\Download\\Python\\testPythonFiles\\instance_snatch_web\\snatch2.txt"
save_path="D:\\snatch2.txt"
# save_path 's file unnecessary to be exist
f_obj = open(save_path,'wb')
f_obj.write(source_stram.read())
print("snatch successfully.")
运行效果:
其它例子:
http://blog.csdn.net/cay22/article/details/8636623
python3.x中的urllib模块
http://my.oschina.net/u/999436/blog/113317
python 3.0 change log:
http://www.python.org/download/releases/3.0.1/NEWS.txt