-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathbasic.py
More file actions
131 lines (97 loc) · 3.29 KB
/
basic.py
File metadata and controls
131 lines (97 loc) · 3.29 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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from PyLinkedinAPI.PyLinkedinAPI import PyLinkedinAPI
# from PyLinkedinAPI.PyLinkedinAPI import PyLinkedinAPIClientError
# from PyLinkedinAPI.PyLinkedinAPI import PyLinkedinAPIInternalServerError
def spaces(n):
print('\n' * n)
def get_content():
comment = input('Insert text: ')
title = input('Insert title: ')
description = input('Insert description: ')
site = input('Insert URL site: ')
image = input('Insert URL image: ')
return comment, title, description, site, image
def get_basic_profile():
linkedin = PyLinkedinAPI(access_token)
profile = linkedin.get_basic_profile()
spaces(1)
print(profile)
def get_companies():
linkedin = PyLinkedinAPI(access_token)
companies = linkedin.get_companies()
spaces(1)
print(companies)
def get_profile():
linkedin = PyLinkedinAPI(access_token)
fields = input(
'Enter fields separated by commas without spaces \nEx: id,email-address,... : ')
companies = linkedin.get_profile(fields.split(','))
spaces(1)
print(companies)
def publish_text_on_profile():
linkedin = PyLinkedinAPI(access_token)
comment = input('Enter text: ')
data = linkedin.publish_profile_comment(comment)
spaces(1)
print(data)
def publish_text_on_company():
linkedin = PyLinkedinAPI(access_token)
id = int(input('Enter id(integer) company: '))
comment = input('Enter text: ')
data = linkedin.publish_company_comment(id, comment)
spaces(1)
print(data)
def publish_on_profile():
linkedin = PyLinkedinAPI(access_token)
comment, title, description, site, image = get_content()
data = linkedin.publish_profile(comment,
title=title,
description=description,
submitted_url=site,
submitted_image_url=image)
spaces(1)
print(data)
def publish_on_company():
linkedin = PyLinkedinAPI(access_token)
id = int(input('Enter id(integer) company: '))
comment, title, description, site, image = get_content()
data = linkedin.publish_company(id,
comment,
title=title,
description=description,
submitted_url=site,
submitted_image_url=image)
spaces(1)
print(data)
access_token = input('Insert Access Token: ')
while True:
print(
'''
>>> 0 - Exit
>>> 1 - Get Basic Profile
>>> 2 - Get Companies
>>> 3 - Get Profile with fields
>>> 4 - Publish only text on Profile
>>> 5 - Publish only text on Company
>>> 6 - Publish content on Profile
>>> 7 - Publish content on Company
'''
)
op = input('Enter option: ')
func = {
'1': get_basic_profile,
'2': get_companies,
'3': get_profile,
'4': publish_text_on_profile,
'5': publish_text_on_company,
'6': publish_on_profile,
'7': publish_on_company,
}
if op not in func.keys():
exit()
try:
func[op]()
except Exception as ex:
spaces(2)
print('Error: {}'.format(ex))