Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import getpass
- import requests
- import re
- user = input('Usuario: ')
- password = getpass.getpass()
- s = requests.Session()
- def do_login(user, password):
- global s
- payload = {
- 'do': 'login',
- 'url': '/foro/',
- 'vb_login_md5password': '',
- 'vb_login_md5password_utf': '',
- 's': '',
- 'vb_login_username': user,
- 'vb_login_password': password,
- 'logb2': 'Entrar',
- 'cookieuser': 1
- }
- response = s.post('https://m.forocoches.com/foro/login.php', data=payload)
- return 'Bienvenido' in response.text
- def get_number_thread():
- global s
- response = s.get('https://m.forocoches.com/foro/newthread.php?do=newthread&f=8')
- text = response.text
- poststarttime = re.search('poststarttime" value="(\d+)"', text).group(1)
- posthash = re.search('posthash" value="([a-f0-9]+)', text).group(1)
- securitytoken = re.search('securitytoken" value="([a-f0-9\-]+)', text).group(1)
- loggedinuser = re.search('loggedinuser" value="(\d+)', text).group(1)
- payload = {
- 'subject': 'Prueba de hilo',
- 'message': 'Prueba de hilo!!<br>',
- 'wysiwyg': 1,
- 's': '',
- 'securitytoken': securitytoken,
- 'f': 8,
- 'do': 'postthread',
- 'posthash': posthash,
- 'poststarttime': poststarttime,
- 'loggedinuser': loggedinuser,
- 'parseurl': 1,
- 'signature': 1,
- 'sbutton': 'Enviar+Nuevo+Tema'
- }
- url = 'https://m.forocoches.com/foro/newthread.php?do=postthread&f=8'
- response = s.post(url, data=payload)
- print("Hilo creado, {}".format(response.url))
- return int(re.search('"t" value="(\d+)', response.text).group(1))
- def is_valid_thread(html):
- if 'forumdisplay.php?f=2"' in html:
- if 'serio' not in html.lower():
- return True
- return False
- def make_poles_starting_at(thread_id):
- global s
- thread_id = thread_id + 1
- while(True):
- response = s.get("https://m.forocoches.com/foro/showthread.php?p={}".format(thread_id))
- # Existe el hilo
- if 'Tema especificado.' not in html:
- if is_valid_thread(response.text):
- url = "https://m.forocoches.com/foro/newreply.php?do=postreply&t={}".format(thread_id)
- text = response.text
- securitytoken = re.search('securitytoken" value="([a-f0-9\-]+)', text).group(1)
- loggedinuser = re.search('loggedinuser" value="(\d+)', text).group(1)
- payload = {
- 'message': 'Poleee',
- 'wysiwyg': 0,
- 'styleid': 7,
- 'signature': 1,
- 'fromquickreply': 1,
- 's': '',
- 'securitytoken': securitytoken,
- 'do': 'postreply',
- 't': thread_id,
- 'p': 'who+cares',
- 'parseurl': 1,
- 'loggedinuser': loggedinuser,
- 'sbutton': 'Enviar+Respuesta'
- }
- response = s.post(url, data=payload)
- print("Pole hecha en un nuevo hilo => {}".format(response.url))
- thread_id += 1
- if do_login(user, password):
- print("Login correcto {}".format(user))
- thread_id = get_number_thread()
- print("Continuando a partir del hilo: {}".format(thread_id))
- make_poles_starting_at(thread_id)
- else:
- print("Login incorrecto")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement