MCPcopy Index your code
hub / github.com/EvanLi/Github-Ranking / get_api_repos

Function get_api_repos

source/common.py:39–59  ·  view source on GitHub ↗

get repos of api, return repos list

(API_URL)

Source from the content-addressed store, hash-verified

37
38
39def get_api_repos(API_URL):
40 """
41 get repos of api, return repos list
42 """
43 access_token = get_access_token()
44 headers = {
45 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.113 Safari/537.36',
46 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9',
47 'Accept-Language': 'zh-CN,zh;q=0.9',
48 'Authorization': 'token {}'.format(access_token),
49 }
50 s = requests.session()
51 s.keep_alive = False # don't keep the session
52 time.sleep(3) # not get so fast
53 # requests.packages.urllib3.disable_warnings() # disable InsecureRequestWarning of verify=False,
54 r = requests.get(API_URL, headers=headers)
55 if r.status_code != 200:
56 raise ValueError('Can not retrieve from {}'.format(API_URL))
57 repos_dict = json.loads(r.content)
58 repos = repos_dict['items']
59 return repos
60
61
62def get_graphql_data(GQL):

Callers

nothing calls this directly

Calls 1

get_access_tokenFunction · 0.85

Tested by

no test coverage detected