Python Time 'Lag' Effect in URL -


my server's timezone , data have fetched via following span 2 consecutive hours. once hour changes, hour python syntax getting not found on server providing content, since server jumps next hour while data not processed yet. in case wondering data in question weather model data in .grib2 format.

i have following code now:

# /usr/bin/python  import time  # save url variable:  url = time.strftime("http://nomads.ncep.noaa.gov/pub/data/nccf/nonoperational/com/hrrr/para/hrrr.%y%m%d/hrrr.t%hz.wrfnatf04.grib2")  # save string file:  open('hrrr/hrrrf4.txt', 'a') f: f.write(url+'\n') 

is there way 'lag' &h variable in above url 1 hour, or method delay ensure smooth data processing desired hours?

thank taking time answer question.

the code below print out datetime of now, , offset subtracting 1 hour, add hour, or minutes, seconds, etc.... scrape lots of forums in different timezones scraping server , that's how adjust anyway. helps if servers clock off little bit too, adjust time of forward need.

import datetime   timenow = datetime.datetime.now()  timeonehourago = timenow - datetime.timedelta(hours=1)  url = timenow.strftime("http://nomads.ncep.noaa.gov/pub/data/nccf/nonoperational/com/hrrr/para/hrrr.%y%m%d/hrrr.t%hz.wrfnatf04.grib2")  offseturl = timeonehourago.strftime("http://nomads.ncep.noaa.gov/pub/data/nccf/nonoperational/com/hrrr/para/hrrr.%y%m%d/hrrr.t%hz.wrfnatf04.grib2")  print url print offseturl 

Comments

Popular posts from this blog

javascript - how to protect a flash video from refresh? -

visual studio 2010 - Connect to informix database windows form application -

android - Associate same looper with different threads -