Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import requests
- from hashlib import md5
- from time import sleep, time
- '''
- TODO:
- Login [x]
- Register
- Thanks
- Shoutbox
- '''
- class Account:
- logged_in = False
- username = ''
- profile_id = None
- def md5(self, string):
- m = md5()
- m.update(string.encode('utf-8'))
- return m.hexdigest()
- def login(self, username, password):
- try:
- self.session = requests.Session()
- r = self.session.get('http://www.gta-sarp.com/forums', timeout=10)
- self.cookie = r.headers['Set-Cookie']
- self.username = username
- self.password = self.md5(password)
- self.headers = {
- 'Set-Cookie':self.cookie, # Uses the cookie from the above get request
- 'User-Agent':'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2840.99 Safari/537.36', }
- data = {
- 'vb_login_username':self.username,
- 'vb_login_password': '',
- 'vb_login_password_hint':'Password',
- 'securitytoken':'guest',
- 'do':'login',
- 'vb_login_md5password':self.password,
- 'vb_login_md5password_utf':self.password
- }
- r = self.session.post('http://www.gta-sarp.com/forums/login.php', headers=self.headers, data=data)
- if('Redirecting...' in r.text):
- self.logged_in = True
- print('Successfully logged into: {}'.format(username))
- sleep(2)
- r = self.session.get('http://www.gta-sarp.com/forums/')
- else:
- print('Invalid username or password')
- except:
- return 'Could not connect to host.'
- def shout(self, message): # Not working yet.
- if not(self.logged_in): return print('You must be logged in to shout.')
- if(self.profile_id == None): return print('You must set your profile ID with the code "account.profile_id = [ID HERE]" to use this feature.')
- data = {
- 'bb_userid':self.profile_id,
- 'do':'ajax',
- 'message':message,
- 'bb_password':self.password,
- 'tabid':'shouts',
- 'pmtime':int(time()),
- 'action':'save'
- }
- self.session.post('http://www.gta-sarp.com/forums/vbshout.php', headers=self.headers, data=data)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement