Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import requests
- import bs4
- import sys
- g_session = requests.Session()
- def Login():
- User = 'vananXX@gmail.com'
- Pass = 'tienl0i999999999'
- url = 'https://id.unica.vn/login'
- try:
- r = g_session.get(url)
- if r.status_code != 200:
- print("Loi server") # print instead of return
- sys.exit(1)
- except Exception as e:
- print("Loi: %s - url: %s", e, url) # print instead of return
- return False
- sauce = r.text # r.text
- soup = bs4.BeautifulSoup(sauce, 'lxml')
- lst = []
- for x in soup.find_all('meta'):
- lst.append(x.get('content'))
- authenticity_token = lst[0]
- if not authenticity_token:
- print("Vui long lien he nha phat trien") # print instead of return
- return False
- payload = { 'user[email]' : User,
- 'user[password]': Pass,
- 'csrf-token' : authenticity_token[0]
- }
- try:
- r = g_session.post(url, data = payload)
- if r.status_code != 200:
- print("Loi dang nhap") # print instead of return
- return False # add return
- except Exception as e:
- print("Loi: %s - url: %s", e, url) # print instead of return
- return False
- return True
- if Login():
- print(True)
- else:
- print(False)
Add Comment
Please, Sign In to add comment