I just started to learn python. In this era, it is worthwhile to let scripts replace people to do something.
Download it. Help me download all the fonts on a website...
Import urllibfrom sgmllib import sgmlparserclass urllister (sgmlparser): def reset (Self): sgmlparser. reset (Self) self. URLs = [] def start_a (self, attrs): href = [V for K, V in attrs if k = 'href 'and v.endswith('.zip')] If href: Self. URLs. extend (href) exts = 'a, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, q, R, S, T, U, V, W, X, Y, Z, no 'urls = ['HTTP: // www.3lian.com/ziti/zt2/fonts-' + ele + '.htm' for ele in exts. split (',')] DownLoadURL = [] for URL in URLs: HTTP = urllib. urlopen (URL) htmlsrc = http. read () HTTP. close () parser = urllister () parser. feed (htmlsrc) parser. close () DownLoadURL. extend (parser. URLs) DownLoadURL = ['HTTP: // www.3lian.com/ziti/zt2/' + ele for ele in DownLoadURL] For URL in DownLoadURL: filename = 'd: \ tddownload \ font-en \ '+ URL. split ('/') [-1] print filename zipfile = open (filename, 'wb') print 'Download --- '+ url http = urllib. urlopen (URL) zipfile. write (HTTP. read () HTTP. close () zipfile. close