下载libdispatch脚本

最近刚接触python,解决了一个以前无法解决的问题,就是下载苹果开源项目的代码问题,话不多说送上我写的脚本,希望对你有用:

#!/usr/bin/python
# coding=utf-8
import requests
import os
import re
import sys, getopt

def download_file(url, home_path):
    if not home_path.endswith("/"):
        home_path = home_path + "/"

    if not url.endswith("/"):
        url = url + "/"

    print "url: "+ url
    print "home_path: " + home_path
    r = requests.get(url)
    html = r.text
    #筛选数据
    text_array = html.split("\n")
    for line in text_array:
        match = re.match(r'^(){1}(){3}(){1}$', line)
        match1 = re.findall(r'

使用方法:

python Test.py -u "https://opensource.apple.com/source/libdispatch/libdispatch-187.10/" -o "你要保存代码的地方"

你可能感兴趣的:(下载libdispatch脚本)