-
Notifications
You must be signed in to change notification settings - Fork 1
/
login.py
68 lines (53 loc) · 2.06 KB
/
login.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
from getpass import getpass
import requests
from bs4 import BeautifulSoup
from constants import *
class Myinfo:
def __init__(self):
self.email = ""
self.password = ""
self.login_session = None
self.my_name = ""
def make_login_request(self, email : str = 'leejungyoon@gmai.com',
password: str = 'bobforever'):
return {
"userId": email,
"userPwd": password,
"state": "email-login",
"autoLoginYn": "N",
"withdrawDate": "",
"telecomCd": "",
"telecomNm": "",
"osType": "",
"osVersion":"",
"deviceModel": "",
"appVersion": "",
"deviceWidth": "",
"deviceHeight": "",
"resultCd": "",
"resultMsg": ""
}
def check_login(self, soup):
try:
myname = soup.find('span', {'class', 'name'}).text
except:
print('-----------------로그인 실패------------------')
return False
return myname
def login(self):
while True:
# self.email = input('이메일을 입력하세요 : ')
# self.password = getpass('비밀번호를 입력하세요 : ')
with requests.Session() as sess:
login_request = self.make_login_request(email =self.email,
password=self.password)
res = sess.post(THE_CAMP_LOGIN_URL, headers=REAQUEST_HEADERS, data=login_request)
login_get = sess.get(THE_CAMP_MEMBER_URL, headers=REAQUEST_HEADERS)
login_soup = BeautifulSoup(login_get.text, 'html.parser')
username = self.check_login(login_soup)
if username != False:
print("로그인 성공 : {}".format(username))
print('')
self.login_session = sess
self.my_name = username
return sess