-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapi_requests.py
More file actions
46 lines (39 loc) · 1.25 KB
/
Copy pathapi_requests.py
File metadata and controls
46 lines (39 loc) · 1.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import requests
from request_settings import *
current_page = 0
current_max_page = DEFAULT_MAX_PAGE
def get_prs_from_repo(url, reset_counter = False, max_count = DEFAULT_MAX_PAGE):
"""
input: url of pull requests,
whether the user wishes to reset the page counter,
and the maximum page one wants to get
output: the next page of pull requests from the url
"""
global current_page, current_max_page
if reset_counter:
current_page = 0
if max_count != DEFAULT_MAX_PAGE:
current_max_page = max_count
current_page += 1
if current_page > current_max_page:
current_page = 0
return []
print("---- getting page " + str(current_page))
response = requests.get(url, params = get_PR_params(current_page), headers = token_header())
temp_prs = response.json()
if response.status_code != 200 or temp_prs == []:
current_page = 0
return []
return temp_prs
def get_html(url):
"""
input: url to html page
output: content of html page
"""
return requests.get(url).content
def get_github_content(url):
"""
input: url of github api call
output: data of the github api call as json
"""
return requests.get(url, headers = token_header()).json()