only download new files (wget -N) in python -


i trying use python package download new files. can download like

outdir = "" url = "" filename = wget.download(url, out=outdir) 

but how can tell wget download new files? in command line did

wget -n url 

which downloads new files. python package wget not seem have equivalent -n flag? know whether there way wget python or there python package can that?

if wget library talking about, built on top of urllib rather being wrapper around wget. have couple options.

  • if want -n functionality library you'll have implement yourself. here how wget determines new file. there 3 different techniques used accomplish this. looks file names not exist. http looks last-modified header. ftp uses list command tries parse output if output same output ls -l command.

  • if running script on system wget executable in path can use subprocess.

here code that.

import subprocess url = '' subprocess.popen(['wget', '-n', url]) 

Comments

Popular posts from this blog

Command prompt result in label. Python 2.7 -

javascript - How do I use URL parameters to change link href on page? -

amazon web services - AWS Route53 Trying To Get Site To Resolve To www -