def test_get_date_from_year_to_day(self): res = dat.get_date_from_year_to_day() assert re.search('^\d{4}_\d\d_\d\d$', res) # res = dat.get_date_from_year_to_day(separator=True) assert re.search('^\d{4}_\d\d_\d\d$', res) # res = dat.get_date_from_year_to_day(separator=False) assert re.search('^\d{8}$', res)
def test_get_date_from_year_to_day(self): res = dat.get_date_from_year_to_day() assert re.search('^\d{4}_\d\d_\d\d$', res) # res = dat.get_date_from_year_to_day(separator=True) assert re.search('^\d{4}_\d\d_\d\d$', res) # res = dat.get_date_from_year_to_day(separator=False) assert re.search('^\d{8}$', res)
def get_subdir_name(url): file_name = os.path.split(urlparse(url)[2])[1] file_base_name= os.path.splitext(file_name)[0] tmp = os.path.split(urlparse(url)[2]) guid = os.path.split(tmp[0])[1] return "{stamp}_{guid}_{desc}".format(stamp=get_date_from_year_to_day(), guid=guid, desc=file_base_name)
def extract(): text = web.get_page(URL) text = text.split('g_img={url:')[1] text = text.split(',')[0].replace("'", "") img_url = urljoin(URL, text) fname = img_url.split('/')[-1] img_ext = os.path.splitext(fname)[1] save_name = get_date_from_year_to_day() + img_ext return (img_url, save_name)
def extract(test=False): text = web.get_page(URL) text = text.split('g_img={url:')[1] text = text.split(',')[0].replace("'", "") img_url = urljoin(URL, text) fname = img_url.split('/')[-1] fname = unquote(fname).split('/')[-1] if not test: print '# fname:', fname save_name = '{date}-{fname}'.format(date=get_date_from_year_to_day(), fname=fname) return (img_url, save_name)
def extract(test=False): text = web.get_page(URL) text = text.split('g_img={url:')[1] text = text.split(',')[0].replace("'", "") img_url = urljoin(URL, text) fname = img_url.split('/')[-1] fname = unquote(fname).split('/')[-1] if not test: print '# fname:', fname save_name = '{date}-{fname}'.format(date=get_date_from_year_to_day(), fname=fname) return (img_url, save_name)
def download(url): fname = url.split('/')[-1] save_name = '{date}-{fname}'.format(date=get_date_from_year_to_day(), fname=fname) # dest = "{dir}/{sname}".format(dir=SAVE_DIR, sname=save_name) cmd = "wget '{url}' -O {dest}".format(url=url, dest=dest) if os.path.isfile(dest): os.unlink(dest) os.system(cmd) print '# saved to', dest return dest
def download(url): fname = url.split('/')[-1] save_name = '{date}-{fname}'.format(date=get_date_from_year_to_day(), fname=fname) # dest = "{dir}/{sname}".format(dir=SAVE_DIR, sname=save_name) cmd = "wget '{url}' -O {dest}".format(url=url, dest=dest) if os.path.isfile(dest): os.unlink(dest) os.system(cmd) print '# saved to', dest return dest
def test_get_date_from_year_to_day(self): res = dat.get_date_from_year_to_day() assert re.search('^\d{4}_\d\d_\d\d$', res)