zoukankan      html  css  js  c++  java
  • elemnetui 下载,及引用

    一、下载

    # encoding:utf-8
    from bs4 import BeautifulSoup
    import requests, re, os, socket
    from urllib import request
    #指定要下载的版本
    element_ui_version = "2.13.0"
    # 指定文件要存放的位置
    element_ui_dir = "D:download"
    
    
    save_ui_dir = os.path.join(element_ui_dir,"element-ui")
    
    if not os.path.isdir(save_ui_dir):
        os.makedirs(save_ui_dir)
    
    element_ui_url = "https://unpkg.com/browse/element-ui@" + element_ui_version + "/"
    headers = {
        "User-Agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:73.0) Gecko/20100101 Firefox/73.0"
    }
    
    def get_page(url,save_dir):
        print("Current Page:",url)
        response = requests.get(url,headers=headers)
        soup = BeautifulSoup(str(response.content), "lxml")
        tbody = soup.find("tbody")
        rule_name = r'href="(.+?)"'
        td_href = re.findall(rule_name,str(tbody))
        dir_list = []
        for href in td_href:
            href_path = os.path.join(save_dir, href)
            if href == "../":
                pass
            elif "/" in href:
    
                os.mkdir(href_path)
                print("Makedir:    ",href_path.replace(save_ui_dir,""))
                dir_list.append(href)
            else:
                file_url = url + href
                abs_name = file_url.replace(element_ui_url, "")
                print("Download:    ", abs_name)
                get_file(file_url,href_path)
    
    
        for sub_dir in dir_list:
            sub_url = url + sub_dir
            sub_dir = os.path.join(save_dir,sub_dir)
            get_page(sub_url,sub_dir)
    
    def get_file(url,filename):
        opener =request.build_opener()
        opener.addheaders = [('User-agent',
                              'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:73.0) Gecko/20100101 Firefox/73.0')]
        request.install_opener(opener)
        socket.setdefaulttimeout(30)
        url = url.replace("browse/","")
        count = 1
        while count <= 5:
            try:
                request.urlretrieve(url, filename)
                break
            except socket.timeout:
                err_info = '<Timeout>   Reloading for %d time' % count
                print(err_info)
                count += 1
            except Exception as e:
                err_info = '<'+str(e)+'>   Reloading for %d time' % count
                print(err_info)
                count += 1
        if count > 5:
            print("<Error>  download job failed!")
        else:
            pass
    
    
    get_page(element_ui_url,save_ui_dir)

    二、引用

    <link rel="stylesheet" href="/static/element-ui/lib/theme-chalk/index.css">
    {#<script src="//unpkg.com/vue/dist/vue.js"></script>#}
    <script src="/static/vue.js"></script>
    <script src="/static/element-ui/lib/index.js"></script>
    {#<script src="//unpkg.com/element-ui@2.13.1/lib/index.js"></script>d#}
    <script src="/static/index.js"></script>
  • 相关阅读:
    AIMS 2013中的性能报告工具不能运行的解决办法
    读懂AIMS 2013中的性能分析报告
    在线研讨会网络视频讲座 方案设计利器Autodesk Infrastructure Modeler 2013
    Using New Profiling API to Analyze Performance of AIMS 2013
    Map 3D 2013 新功能和新API WebCast视频下载
    为Autodesk Infrastructure Map Server(AIMS) Mobile Viewer创建自定义控件
    ADN新开了云计算Cloud和移动计算Mobile相关技术的博客
    JavaScript修改css样式style
    文本编辑神器awk
    jquery 开发总结1
  • 原文地址:https://www.cnblogs.com/wt7018/p/12979381.html
Copyright © 2011-2022 走看看