- 积分
- 2188
- 贡献
-
- 精华
- 在线时间
- 小时
- 注册时间
- 2012-11-20
- 最后登录
- 1970-1-1
|
登录后查看更多精彩内容~
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
github地址:https://github.com/smft/scrapy_radar_img
忽然间发现国家局无法下载(自动回复:请不要使用迅雷等下载工具,点我查看下载帮助)雷达综合反射率历史图片了,看来只能自己动手每天扒一扒了。存下来的图说不定有朝一日可以卖钱。。。
请记住,将此进程写进定时任务中,包你每天神清气爽一辈子。
先看配置文件,该文件用于存放区域雷达拼图名称,雷达站点编号。供程序调用。
- ANEC
- ANCN
- AECN
- ACCN
- ASCN
- ASWC
- ANWC
- ABCJ
- ABHH
- ACES
- Z9210
- Z9002
- Z9250
- Z9518
- Z9516
- Z9513
- Z9515
- Z9519
- Z9517
- Z9523
- Z9555
- Z9551
- Z9558
- Z9556
- Z9559
- Z9562
- Z9563
- Z9570
- Z9574
- Z9577
- Z9571
- Z9579
- Z9580
- Z9576
- Z9572
- Z9578
- Z9531
- Z9535
- Z9532
- Z9538
- Z9543
- Z9539
- Z9536
- Z9631
复制代码 下面是主程序,思路就是python调用wget。
- # -*- coding: utf-8 -*-
- """
- wget radar ref gif from CMA
- @author: qzhang
- """
-
- import os
- import string
- import time
- import smtplib
- from email.mime.text import MIMEText
- from email.mime.multipart import MIMEMultipart
- def get_img(year_in,month_in,day_in,station_info,path_to_save):
- hr=["00","01","02","03","04","05","06","07","08","09","10","11","12","13","14","15","16","17","18","19","20","21","22","23"]
- mi=["00","10","20","30","40","50"]
- se=["00"]
- if station_info[0]=="A":
- image_path="mosaic"
- if station_info[0]=="Z":
- image_path="image"
- for hr_cell in hr:
- hr_str=hr_cell
- for mi_cell in mi:
- mi_str=mi_cell
- for se_cell in se:
- se_str=se_cell
- url_path="http://www.moc.cma.gov.cn/mocimg/radar/"+image_path+"/"+station_info+"/QREF/"+year_in+"/"+month_in+"/"+day_in+"/"+station_info+\
- ".QREF000."+year_in+month_in+day_in+"."+hr_str+mi_str+se_str+".GIF"
- save_path=path_to_save+station_info+"/"
- os.system("wget -P "+save_path+" "+url_path)
- flag=year_in+month_in+day_in+hr_str+mi_str
- print flag
- return 0
- site_flag=open("./radar_site.ini","r")
- path_to_save="/home/qzhang/radar_img/"
- site_info=site_flag.read().split("\n")
- yesterday=time.strftime("%Y-%m-%d-%H-%M-%S",time.localtime(time.time()-86400)).split("-")
- record=[]
- for site_cell in site_info[:-1]:
- station_info=site_cell
- flag=get_img(yesterday[0],yesterday[1],yesterday[2],station_info,path_to_save)
- if flag==0:
- record+=[station_info+" !!!success!!!"]
- else:
- record+=[station_info+"!!!fail!!!"]
- if os.system("tar -cvf ~/radar_img_"+yesterday[0]+yesterday[1]+yesterday[2]+".tar.gz "+path_to_save):
- record+=["tar file !!!success!!!"]
- else:
- record+=["tar file !!!fail!!!"]
- if os.system("rm -r "+path_to_save):
- record+=["rm file !!!success!!!"]
- else:
- record+=["rm file !!!fail!!!"]
- for cell in record:
- print cell
- print time.strftime("%Y-%m-%d-%H-%M-%S",time.localtime(time.time()))
复制代码 最后,截图证明可行
|
评分
-
查看全部评分
|