Python下载163yum源文件

2019年8月3日23:18:38 评论 710

用于搭建本地yum源,编写了一个小脚本,将163官方站点的yum文件全部下载到本地。

    #!/usr/bin/python
    import requests
    from bs4 import BeautifulSoup
    import os
    link_list = []
    downurl = []
    s = requests.session()
    url = "http://mirrors.163.com/centos/7/os/x86_64/Packages/"
    response = s.get(url)
    text = response.text
    soup = BeautifulSoup(response.content,'lxml')
    a = soup.find_all('a')
    for x in a:
        link = x.get('href')
        if link:link_list.append(link)
    for filename in link_list:
        down = url + filename
        downurl.append(down)
        get = os.popen("wget %s"%down)
        print get.read()

http://www.oniont.cn/index.php/archives/5.html

高性能云服务器2折起

发表评论

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: