强妈看世界 發表於 2021-8-22 16:17:00

批量删除gitee的代码库

<p>先获取令牌,然后再console中执行。</p>
<div class="cnblogs_code">
<pre>(async <span style="color: rgba(0, 0, 255, 1)">function</span><span style="color: rgba(0, 0, 0, 1)">() {
    let resp </span>= await fetch("https://gitee.com/api/v5/users/yourname/repos?access_token=#your_token_string#&amp;type=all&amp;sort=full_name&amp;direction=asc&amp;page=1&amp;per_page=100"<span style="color: rgba(0, 0, 0, 1)">, {
      </span>"headers"<span style="color: rgba(0, 0, 0, 1)">: {
            </span>"accept": "application/json, text/plain, */*"<span style="color: rgba(0, 0, 0, 1)">,
            </span>"content-type": "application/json;charset=utf-8"<span style="color: rgba(0, 0, 0, 1)">
      },
      </span>"referrer": "https://gitee.com/api/v5/swagger"<span style="color: rgba(0, 0, 0, 1)">,
      </span>"referrerPolicy": "strict-origin-when-cross-origin"<span style="color: rgba(0, 0, 0, 1)">,
      </span>"body": <span style="color: rgba(0, 0, 255, 1)">null</span><span style="color: rgba(0, 0, 0, 1)">,
      </span>"method": "GET"<span style="color: rgba(0, 0, 0, 1)">,
      </span>"mode": "cors"<span style="color: rgba(0, 0, 0, 1)">,
      </span>"credentials": "include"<span style="color: rgba(0, 0, 0, 1)">
    });

    let list </span>=<span style="color: rgba(0, 0, 0, 1)"> await resp.json();
    let fetchurls </span>= list.filter((v,i)=&gt;v.full_name.indexOf('/cto-') &gt; 0).map((v,i)=&gt;'https://gitee.com/api/v5/repos/' + v.full_name + '?access_token=#your_token_string#'<span style="color: rgba(0, 0, 0, 1)">);
    </span><span style="color: rgba(0, 0, 255, 1)">for</span> (<span style="color: rgba(0, 0, 255, 1)">var</span> i = 0, c = fetchurls.length; i &lt; c; i++<span style="color: rgba(0, 0, 0, 1)">) {
      let url </span>=<span style="color: rgba(0, 0, 0, 1)"> fetchurls;
      await fetch(url, {
            method: </span>'DELETE'<span style="color: rgba(0, 0, 0, 1)">,
            headers: {
                </span>"Content-Type": "application/json;charset=UTF-8"<span style="color: rgba(0, 0, 0, 1)">
            }
      })
    }
    console.log(</span>'ok'<span style="color: rgba(0, 0, 0, 1)">)
}
)();</span></pre>
</div>
<p>&nbsp;</p>

</div>
<div id="MySignature" role="contentinfo">
    QQ:273352165
evlon#126.com
转载请注明出处。<br><br>
来源:https://www.cnblogs.com/evlon/p/15172604.html
頁: [1]
查看完整版本: 批量删除gitee的代码库