github 下载速度太慢了。
先用导入到码云再下载下来,而后到.git/config
修改git repo url 为原来的
仍是有点麻烦,那就作成一个工具吧。
# 获取登录页面 import re import requests s = requests.Session() headers = {'User-Agent': 'Mozilla/5.0 Gecko/20100101'} url_login = 'https://gitee.com/login' resp_get_login = s.get(login_url, headers=headers) def parse_token(response): # 解析 token result = re.search('<meta content="(.*?)" name="csrf-token"', response.text) return result.group(1)
详细代码,参考个人repo git2giteepython
''' 根据公钥加密方法。对应开头为 encrypt 的js文件 ''' from base64 import b64encode from Crypto.PublicKey import RSA from Crypto.Cipher import PKCS1_v1_5 def encrypt_pwd(password, public_key): ''' :params public_key: -----BEGIN PUBLIC KEY----\nkeys\n-----END ...----- :params password: csrf-token + '$gitee$' + password ''' rsa_key = RSA.import_key(public_key) encryptor = PKCS1_v1_5.new(rsa_key) cipher = b64encode(encryptor.encrypt(password.encode('utf-8'))) return cipher.decode('utf-8')
pip install git2gitee
# 参数说明 -u 用户名 -k 密码 repo地址 https 协议开头的 git2gitee -u mikele -k not_real_password repo_url
[] 检查是否有人已经导入过了
[] 检查是否公开的repo
[] 下载到本地,自动修改config urlgit