爱气象,爱气象家园! 

气象家园

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博登陆

只需一步, 快速开始

搜索
查看: 8683|回复: 11

求助:windows下使用python下载FNL

[复制链接]

新浪微博达人勋

发表于 2018-10-10 11:14:19 | 显示全部楼层 |阅读模式

登录后查看更多精彩内容~

您需要 登录 才可以下载或查看,没有帐号?立即注册 新浪微博登陆

x
本帖最后由 Dahoe 于 2018-10-10 11:17 编辑

在下想下载fnl资料,在下载界面点了windows和python出现如下脚本,然后在文本文档里复制粘贴保存成.py格式,cmd中运行python *.py出现如下错误该怎么办?求助各位大神 万分感谢
:: python script to download selected files from rda.ucar.edu::import sysimport osimport urllib2import cookielib::if (len(sys.argv) != 2):  print "usage: "+sys.argv[0]+" [-q] password_on_RDA_webserver"  print "-q suppresses the progress message for each file that is downloaded"  sys.exit(1)::passwd_idx=1verbose=Trueif (len(sys.argv) == 3 and sys.argv[1] == "-q"):  passwd_idx=2  verbose=False::cj=cookielib.MozillaCookieJar()opener=urllib2.build_opener(urllib2.HTTPCookieProcessor(cj)):::: check for existing cookies file and authenticate if necessarydo_authentication=Falseif (os.path.isfile("auth.rda.ucar.edu")):  cj.load("auth.rda.ucar.edu",False,True)  for cookie in cj:    if (cookie.name == "sess" and cookie.is_expired()):      do_authentication=Trueelse:  do_authentication=Trueif (do_authentication):  login=opener.open("https://rda.ucar.edu/cgi-bin/login","email=&password="+sys.argv[1]+"&action=login"):::: save the authentication cookies for future downloads:: NOTE! - cookies are saved for future sessions because overly-frequent authentication to our server can cause your data access to be blocked  cj.clear_session_cookies()  cj.save("auth.rda.ucar.edu",True,True):::: download the data file(s)listoffiles=["grib2/2017/2017.01/fnl_20170101_00_00.grib2","grib2/2017/2017.01/fnl_20170101_06_00.grib2","grib2/2017/2017.01/fnl_20170101_12_00.grib2","grib2/2017/2017.01/fnl_20170101_18_00.grib2","grib2/2017/2017.01/fnl_20170102_00_00.grib2","grib2/2017/2017.01/fnl_20170102_06_00.grib2","grib2/2017/2017.01/fnl_20170102_12_00.grib2","grib2/2017/2017.01/fnl_20170102_18_00.grib2","grib2/2017/2017.01/fnl_20170103_00_00.grib2","grib2/2017/2017.01/fnl_20170103_06_00.grib2","grib2/2017/2017.01/fnl_20170103_12_00.grib2","grib2/2017/2017.01/fnl_20170103_18_00.grib2","grib2/2017/2017.01/fnl_20170104_00_00.grib2","grib2/2017/2017.01/fnl_20170104_06_00.grib2","grib2/2017/2017.01/fnl_20170104_12_00.grib2","grib2/2017/2017.01/fnl_20170104_18_00.grib2","grib2/2017/2017.01/fnl_20170105_00_00.grib2","grib2/2017/2017.01/fnl_20170105_06_00.grib2","grib2/2017/2017.01/fnl_20170105_12_00.grib2","grib2/2017/2017.01/fnl_20170105_18_00.grib2","grib2/2017/2017.01/fnl_20170106_00_00.grib2","grib2/2017/2017.01/fnl_20170106_06_00.grib2","grib2/2017/2017.01/fnl_20170106_12_00.grib2","grib2/2017/2017.01/fnl_20170106_18_00.grib2","grib2/2017/2017.01/fnl_20170107_00_00.grib2","grib2/2017/2017.01/fnl_20170107_06_00.grib2","grib2/2017/2017.01/fnl_20170107_12_00.grib2","grib2/2017/2017.01/fnl_20170107_18_00.grib2","grib2/2017/2017.01/fnl_20170108_00_00.grib2","grib2/2017/2017.01/fnl_20170108_06_00.grib2","grib2/2017/2017.01/fnl_20170108_12_00.grib2","grib2/2017/2017.01/fnl_20170108_18_00.grib2","grib2/2017/2017.01/fnl_20170109_00_00.grib2","grib2/2017/2017.01/fnl_20170109_06_00.grib2","grib2/2017/2017.01/fnl_20170109_12_00.grib2","grib2/2017/2017.01/fnl_20170109_18_00.grib2","grib2/2017/2017.01/fnl_20170110_00_00.grib2","grib2/2017/2017.01/fnl_20170110_06_00.grib2","grib2/2017/2017.01/fnl_20170110_12_00.grib2","grib2/2017/2017.01/fnl_20170110_18_00.grib2","grib2/2017/2017.01/fnl_20170111_00_00.grib2","grib2/2017/2017.01/fnl_20170111_06_00.grib2","grib2/2017/2017.01/fnl_20170111_12_00.grib2","grib2/2017/2017.01/fnl_20170111_18_00.grib2","grib2/2017/2017.01/fnl_20170112_00_00.grib2","grib2/2017/2017.01/fnl_20170112_06_00.grib2","grib2/2017/2017.01/fnl_20170112_12_00.grib2","grib2/2017/2017.01/fnl_20170112_18_00.grib2","grib2/2017/2017.01/fnl_20170113_00_00.grib2","grib2/2017/2017.01/fnl_20170113_06_00.grib2","grib2/2017/2017.01/fnl_20170113_12_00.grib2","grib2/2017/2017.01/fnl_20170113_18_00.grib2","grib2/2017/2017.01/fnl_20170114_00_00.grib2","grib2/2017/2017.01/fnl_20170114_06_00.grib2","grib2/2017/2017.01/fnl_20170114_12_00.grib2","grib2/2017/2017.01/fnl_20170114_18_00.grib2","grib2/2017/2017.01/fnl_20170115_00_00.grib2","grib2/2017/2017.01/fnl_20170115_06_00.grib2","grib2/2017/2017.01/fnl_20170115_12_00.grib2","grib2/2017/2017.01/fnl_20170115_18_00.grib2","grib2/2017/2017.01/fnl_20170116_00_00.grib2","grib2/2017/2017.01/fnl_20170116_06_00.grib2","grib2/2017/2017.01/fnl_20170116_12_00.grib2","grib2/2017/2017.01/fnl_20170116_18_00.grib2","grib2/2017/2017.01/fnl_20170117_00_00.grib2","grib2/2017/2017.01/fnl_20170117_06_00.grib2","grib2/2017/2017.01/fnl_20170117_12_00.grib2","grib2/2017/2017.01/fnl_20170117_18_00.grib2","grib2/2017/2017.01/fnl_20170118_00_00.grib2","grib2/2017/2017.01/fnl_20170118_06_00.grib2","grib2/2017/2017.01/fnl_20170118_12_00.grib2","grib2/2017/2017.01/fnl_20170118_18_00.grib2","grib2/2017/2017.01/fnl_20170119_00_00.grib2","grib2/2017/2017.01/fnl_20170119_06_00.grib2","grib2/2017/2017.01/fnl_20170119_12_00.grib2","grib2/2017/2017.01/fnl_20170119_18_00.grib2","grib2/2017/2017.01/fnl_20170120_00_00.grib2","grib2/2017/2017.01/fnl_20170120_06_00.grib2","grib2/2017/2017.01/fnl_20170120_12_00.grib2","grib2/2017/2017.01/fnl_20170120_18_00.grib2","grib2/2017/2017.01/fnl_20170121_00_00.grib2","grib2/2017/2017.01/fnl_20170121_06_00.grib2","grib2/2017/2017.01/fnl_20170121_12_00.grib2","grib2/2017/2017.01/fnl_20170121_18_00.grib2","grib2/2017/2017.01/fnl_20170122_00_00.grib2","grib2/2017/2017.01/fnl_20170122_06_00.grib2","grib2/2017/2017.01/fnl_20170122_12_00.grib2","grib2/2017/2017.01/fnl_20170122_18_00.grib2","grib2/2017/2017.01/fnl_20170123_00_00.grib2","grib2/2017/2017.01/fnl_20170123_06_00.grib2","grib2/2017/2017.01/fnl_20170123_12_00.grib2","grib2/2017/2017.01/fnl_20170123_18_00.grib2","grib2/2017/2017.01/fnl_20170124_00_00.grib2","grib2/2017/2017.01/fnl_20170124_06_00.grib2","grib2/2017/2017.01/fnl_20170124_12_00.grib2","grib2/2017/2017.01/fnl_20170124_18_00.grib2","grib2/2017/2017.01/fnl_20170125_00_00.grib2","grib2/2017/2017.01/fnl_20170125_06_00.grib2","grib2/2017/2017.01/fnl_20170125_12_00.grib2","grib2/2017/2017.01/fnl_20170125_18_00.grib2","grib2/2017/2017.01/fnl_20170126_00_00.grib2","grib2/2017/2017.01/fnl_20170126_06_00.grib2","grib2/2017/2017.01/fnl_20170126_12_00.grib2","grib2/2017/2017.01/fnl_20170126_18_00.grib2","grib2/2017/2017.01/fnl_20170127_00_00.grib2","grib2/2017/2017.01/fnl_20170127_06_00.grib2","grib2/2017/2017.01/fnl_20170127_12_00.grib2","grib2/2017/2017.01/fnl_20170127_18_00.grib2","grib2/2017/2017.01/fnl_20170128_00_00.grib2","grib2/2017/2017.01/fnl_20170128_06_00.grib2","grib2/2017/2017.01/fnl_20170128_12_00.grib2","grib2/2017/2017.01/fnl_20170128_18_00.grib2","grib2/2017/2017.01/fnl_20170129_00_00.grib2","grib2/2017/2017.01/fnl_20170129_06_00.grib2","grib2/2017/2017.01/fnl_20170129_12_00.grib2","grib2/2017/2017.01/fnl_20170129_18_00.grib2","grib2/2017/2017.01/fnl_20170130_00_00.grib2","grib2/2017/2017.01/fnl_20170130_06_00.grib2","grib2/2017/2017.01/fnl_20170130_12_00.grib2","grib2/2017/2017.01/fnl_20170130_18_00.grib2","grib2/2017/2017.01/fnl_20170131_00_00.grib2","grib2/2017/2017.01/fnl_20170131_06_00.grib2","grib2/2017/2017.01/fnl_20170131_12_00.grib2","grib2/2017/2017.01/fnl_20170131_18_00.grib2","grib2/2017/2017.02/fnl_20170201_00_00.grib2"]for file in listoffiles:  idx=file.rfind("/")  if (idx > 0):    ofile=file[idx+1:]  else:    ofile=file  if (verbose):    sys.stdout.write("downloading "+ofile+"...")    sys.stdout.flush()  infile=opener.open("http://rda.ucar.edu/data/ds083.2/"+file)  outfile=open(ofile,"wb")  outfile.write(infile.read())  outfile.close()  if (verbose):    sys.stdout.write("done.\n")

密码修改失败请联系微信:mofangbao

新浪微博达人勋

 楼主| 发表于 2018-10-10 11:16:22 | 显示全部楼层
回帖不增加积分,建议坚持签到,多分享!
TIM截图20181010112010.png
密码修改失败请联系微信:mofangbao

新浪微博达人勋

发表于 2018-10-24 14:02:12 | 显示全部楼层
楼主问题解决了吗?
密码修改失败请联系微信:mofangbao

新浪微博达人勋

 楼主| 发表于 2018-10-24 16:15:42 | 显示全部楼层
lovjiangyp 发表于 2018-10-24 14:02
楼主问题解决了吗?

还没,不过我在linux系统用wget下了e
密码修改失败请联系微信:mofangbao

新浪微博达人勋

发表于 2018-10-24 16:27:57 | 显示全部楼层
ip被ban了,想下都没得下
密码修改失败请联系微信:mofangbao

新浪微博达人勋

发表于 2019-1-6 15:07:27 | 显示全部楼层
::替换成#试试
密码修改失败请联系微信:mofangbao

新浪微博达人勋

发表于 2019-2-25 04:09:45 | 显示全部楼层
python+文件py+密码,你没输入网站登陆密码
密码修改失败请联系微信:mofangbao

新浪微博达人勋

发表于 2019-2-25 04:17:38 | 显示全部楼层

python+文件py+密码,你没输入网站登陆密码
py.png
密码修改失败请联系微信:mofangbao

新浪微博达人勋

 楼主| 发表于 2019-2-25 09:02:40 | 显示全部楼层
ldwloveyyz 发表于 2019-2-25 04:17
python+文件py+密码,你没输入网站登陆密码

原来还要加密码 ,谢谢你了
密码修改失败请联系微信:mofangbao

新浪微博达人勋

发表于 2019-4-24 09:04:48 | 显示全部楼层
ldwloveyyz 发表于 2019-2-25 04:17
python+文件py+密码,你没输入网站登陆密码

你好, 我的脚本可以运行,但是一直停留在download file上,下载了一晚上还是这样,我看了下载的文件是0kb,请问你知道原因吗
密码修改失败请联系微信:mofangbao
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册 新浪微博登陆

本版积分规则

Copyright ©2011-2014 bbs.06climate.com All Rights Reserved.  Powered by Discuz! (京ICP-10201084)

本站信息均由会员发表,不代表气象家园立场,禁止在本站发表与国家法律相抵触言论

快速回复 返回顶部 返回列表