-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
51 lines (36 loc) · 1.04 KB
/
main.py
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
47
48
49
50
"""main
1. scrape today's brunch using brunch_scraper module
2. post on github issue
Functions:
_run(category: str = 'IT_트렌드') -> None
"""
import os
import sys
from github import Github
from brunch_scraper import get_title, get_body
def _run(category: str = 'IT_트렌드'):
"""Post github issue
Args:
category: str = 'IT_트렌드'
brunch category
"""
try:
GITHUB_TOKEN = os.environ['GITHUB_TOKEN']
REPO_NAME = 'todays-brunch'
issue_title = get_title(category)
issue_body = get_body(category)
if issue_body == '':
print('There is no updated brunch.')
sys.exit()
repo = Github(GITHUB_TOKEN).get_user().get_repo(REPO_NAME)
res = repo.create_issue(title=issue_title, body=issue_body)
print('Success!')
print(res)
except Exception as e:
print(e)
if __name__ == '__main__':
if len(sys.argv) > 1:
for i in range(1, len(sys.argv)):
_run(sys.argv[i])
else:
_run()