Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import requests
- from bs4 import BeautifulSoup
- import re
- import subprocess
- import os
- from datetime import datetime
- currentDateAndTime = datetime.now()
- headers = {
- 'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:59.0) Gecko/20100101 Firefox/59.0',
- }
- HORA = 19
- done = False
- while True:
- currentDateAndTime = datetime.now()
- hrefs = []
- if done:
- break
- if (currentDateAndTime.hour == HORA):
- home_req = requests.get('https://forocoches.com', headers=headers)
- soup = BeautifulSoup(home_req.text, 'lxml')
- print('Buscando temas con invitaciones...')
- temas = soup.find_all('table', border=0, cellpadding=2, cellspacing=0)[3].tbody.find_all('tr')[0].find_all('td')[0].table.tbody.find_all('tr')[4].td.table.find_all('tr')[1:]
- for tema in temas:
- if tema.find_all('td')[1].string != f'{HORA}:00':
- continue
- if tema.find_all('a')[0].string != 'General':
- continue
- print(f'Posible tema encontrado: ' + tema.find_all('a')[1]['href'])
- hrefs.append(tema.find_all('a')[1]['href'])
- for link in hrefs:
- req = requests.get('https://forocoches.com' + link, headers=headers)
- if re.search('Unas invis para celebrar esta POLE.*$', req.text, flags=re.MULTILINE):
- codigo = re.search('Unas invis para celebrar esta POLE.*$', req.text, flags=re.MULTILINE).group().split(':')[1].strip()
- print(f'Código de invitación conseguido! \n {codigo}')
- subprocess.run("pbcopy", text=True, input=codigo)
- os.system('say "POLEEEEEEEEEEEEEEEEEEEEEEE"')
- done = True
- break
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement