Python同步谷歌Webfont
- https://fonts.googleapis.com/css?family=Roboto:100,200,300,400,600
- http://fonts.useso.com/css?family=Roboto:100,200,300,400,600
- https://fonts-gstatic.proxy.ustclug.org/css?family=Roboto:100,200,300,400,600
打開可以看到其實是css內容:
import commandsnimport rennndef download(url, local): n name = url.split(/)[-1] n cmd_download = curl -o + local + name + + url n print commands.getoutput(cmd_download)n return Truennndef main(org_css_file, dest_css_file, local_fonts_path, org_url, self_url):n _org_css_file = open(org_css_file)n _org_css_str = _org_css_file.read()n _org_css_file.close()nn font_list = re.findall(url(([^)]+)), _org_css_str) n map(lambda url: download(url, local_fonts_path), font_list) n n _dest_css_str = _org_css_str.replace(org_url, self_url)n _dest_css_file = open(dest_css_file,w)n _dest_css_file.write(_dest_css_str)n _dest_css_file.close()nnnmain(n "org.css",n "dest.css",n "s/roboto/v15/",n "https://fonts-gstatic.proxy.ustclug.org/",n "http://static.insta360.com/public/fonts/"n) n
最後的目錄就是醬紫了:
推薦閱讀:
※【譯】如何學習V8開發
※前端與SQL
※每周一書-《Bootstrap基礎教程》
※業內說的大前(大前端)和小前,在職責上有什麼區別?
※如何在懂得不是很多,公司只有一個前端的情況下,更好的鍛煉自己?