Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import requests, json, time, threading
- from bs4 import BeautifulSoup
- from colorama import init, Fore
- import sys
- init()
- def get_page(s, url, headers=None):
- if headers is None:
- return s.get(url, timeout=2)
- return s.get(url, headers=headers, timeout=2)
- def post_page(s, url, payload, headers=None):
- return s.post(url, data=payload, headers=headers, allow_redirects=True, timeout=2)
- def post_invite(s, url, payload, headers=None):
- return s.post(url, data=payload, headers=headers, allow_redirects=True, timeout=2)
- def post_poach(s, url, payload, headers=None):
- return s.post(url, data=payload, headers=headers, timeout=2)
- def get_soup(page):
- return BeautifulSoup(page.content, 'html.parser')
- def get_history(page):
- return page.history
- def login_success(page):
- page_title = page.find('div', class_='page-title')
- if page_title is not None:
- if 'Вход в систему' in page_title.text:
- if page.find('div', attrs={'class': 'error-summary'}).get('style') is None:
- print('Логин или пароль не верный')
- print('Повторите вход')
- return False
- else:
- return True
- def load_cookies():
- with open('cookies.txt', 'r') as f:
- return requests.utils.cookiejar_from_dict(json.load(f))
- def save_cookies(s):
- with open('cookies.txt', 'w', encoding='utf-8') as f:
- json.dump(requests.utils.dict_from_cookiejar(s.cookies), f)
- def check_login_data():
- try:
- with open('login.txt', 'r') as f:
- line = f.readline(1)
- if not line:
- return
- else:
- return True
- except FileNotFoundError:
- return
- def read_login_data():
- with open('login.txt', 'r') as f:
- lines = [line.strip() for line in f.readlines()]
- return (lines[0], lines[1])
- def save_login_data():
- login = input('Введите логин: ').strip()
- password = input('Введите пароль: ').strip()
- with open('login.txt', 'w', encoding='utf-8') as f:
- f.write(login + '\n' + password)
- def net_waiter():
- while True:
- try:
- tmp = requests.get('https://jugl.net/', timeout=2)
- if tmp.status_code == 200:
- # print('Интернет впорядке.\nПродолжаю поиск...')
- break
- except (requests.exceptions.ReadTimeout, requests.exceptions.ConnectionError):
- time.sleep(0.5)
- def exit0():
- global r
- while r:
- tmp = sys.stdin.read(1)
- if '\n' in tmp:
- r = False
- def main():
- s = requests.Session()
- base_url = 'https://jugl.net/'
- if not check_login_data():
- save_login_data()
- while True:
- try:
- login, password = read_login_data()
- headers = {
- 'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36',
- 'Accept-Language': 'ru-RU,ru;q=0.9,en-US;q=0.8,en;q=0.7',
- 'Origin': 'https://jugl.net',
- 'Content-Type': 'application/json;charset=UTF-8',
- # 'x-csrf-token': token,
- 'Referer': 'https://jugl.net/my',
- # 'accept': 'application/json, text/plain, */*',
- 'Accept-Encoding': 'gzip, deflate, br',
- # 'Content-Type': 'application/json;charset=UTF-8'
- }
- token = get_soup(get_page(s, base_url + 'login', headers=headers)).find('input', {'name': '_csrf'}).get('value')
- payload = {'_csrf': token, 'LoginForm[username]': login, 'LoginForm[password]': password}
- logged = login_success(get_soup(post_page(s, base_url + 'login', payload, headers)))
- if logged is False:
- s.cookies.clear()
- save_login_data()
- else:
- break
- except (requests.exceptions.ReadTimeout, requests.exceptions.ConnectionError):
- # print('Проблемы с интернетом.')
- net_waiter()
- success = False
- while not success:
- try:
- my_name = get_page(s, base_url + 'api-user/status').text
- my_name = json.loads(my_name.)
- print(my_name)
- # my_last = json.loads(get_page(s, base_url + 'api-user/status').text[6:]).get('last_name')
- # My_Name = (my_name +' '+ my_last)
- success = True
- except (requests.exceptions.ReadTimeout, requests.exceptions.ConnectionError):
- # print('Проблемы с интернетом.')
- net_waiter()
- print(Fore.GREEN + 'Добро пожаловать', My_Name)
- print('Начинаю поиск новых людей...')
- print('Для отключения бота нажмите Enter')
- exiter = threading.Thread(target=exit0)
- exiter.start()
- User_Invite_New = None
- inviteng = True
- while r:
- # try:
- # requests.get('https://jugl.net/')
- # except requests.exceptions.ConnectionError:
- # print('Проблемы с интернетом.')
- # net_waiter()
- try:
- p1 = 'api-invite-my/list?country_ids=64,10,170,1,2,3,4,5,6,7,8,9,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,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,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,171,172,173,174,175,176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,192,193,194,195,196&pageNum=1'
- result = get_page(s, base_url + p1).text[6:]
- deco_invite = json.loads(result)
- items = deco_invite.get('log').get('items')
- First_name = items[0]['first_name']
- Last_name = items[0]['last_name']
- User_Invite = (First_name + ' ' + Last_name)
- Id = items[0]['id']
- if 'winner' not in items[0] and inviteng:
- print('Пытаюсь пригласить: ' + User_Invite)
- payload = {'_csrf': token, 'id': Id}
- invite = get_soup(post_invite(s, base_url + 'api-invitation/become-member-invite', payload, headers)).text[6:]
- print(json.loads(invite))
- inviteng = False
- continue
- elif 'winner' not in items[0]:
- continue
- User_Invite_Old, User_Invite_New = (User_Invite, User_Invite_New)[User_Invite_New!=None], User_Invite
- User_Winner = items[0]['winner']['userName']
- if My_Name in User_Winner and User_Invite_New!=User_Invite_Old:
- print('Ура пригласил! ' + User_Invite_New)
- elif User_Invite_New!=User_Invite_Old:
- print('К сожалению не пригласил, будем переманивать: ' + User_Invite_New)
- inviteng = True
- time.sleep(2)
- poach_get = get_page(s, base_url + 'api-user-profile/index?id=369060', headers)
- time.sleep(1)
- print(poach_get.text)
- print(poach_get.cookies)
- payload = {'_csrf': token, 'userTeamRequest': {'user': {'name': 'Sylvia jones'}, 'second_user_id': 369060, 'text': "Приветствую Вас, приглашаю к себе в команду, буду во всем помогать для достижения успеха и больших заработков. Предоставлю Вам видео уроки", "saving":'true'}}
- poach = post_page(s, base_url + 'api-user-team-request/save-parent-to-referral', payload, headers)
- print(poach.text)
- print(poach.status_code)
- # print(s.cookies)
- break
- except (requests.exceptions.ReadTimeout, requests.exceptions.ConnectionError):
- # print('Проблемы с интернетом.')
- net_waiter()
- if __name__ == '__main__':
- global r
- r = True
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement