Advertisement
Guest User

Untitled

a guest
Dec 28th, 2022
151
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.81 KB | None | 0 0
  1. import requests
  2. from bs4 import BeautifulSoup
  3. import re
  4. import subprocess
  5. import os
  6. from datetime import datetime
  7.  
  8. currentDateAndTime = datetime.now()
  9.  
  10. headers = {
  11. 'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:59.0) Gecko/20100101 Firefox/59.0',
  12. }
  13.  
  14. HORA = 19
  15. done = False
  16.  
  17. while True:
  18.  
  19. currentDateAndTime = datetime.now()
  20. hrefs = []
  21.  
  22. if done:
  23. break
  24.  
  25. if (currentDateAndTime.hour == HORA):
  26. home_req = requests.get('https://forocoches.com', headers=headers)
  27.  
  28. soup = BeautifulSoup(home_req.text, 'lxml')
  29.  
  30. print('Buscando temas con invitaciones...')
  31. 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:]
  32.  
  33. for tema in temas:
  34.  
  35.  
  36. if tema.find_all('td')[1].string != f'{HORA}:00':
  37. continue
  38. if tema.find_all('a')[0].string != 'General':
  39. continue
  40.  
  41. print(f'Posible tema encontrado: ' + tema.find_all('a')[1]['href'])
  42. hrefs.append(tema.find_all('a')[1]['href'])
  43.  
  44.  
  45. for link in hrefs:
  46. req = requests.get('https://forocoches.com' + link, headers=headers)
  47.  
  48. if re.search('Unas invis para celebrar esta POLE.*$', req.text, flags=re.MULTILINE):
  49. codigo = re.search('Unas invis para celebrar esta POLE.*$', req.text, flags=re.MULTILINE).group().split(':')[1].strip()
  50. print(f'Código de invitación conseguido! \n {codigo}')
  51. subprocess.run("pbcopy", text=True, input=codigo)
  52. os.system('say "POLEEEEEEEEEEEEEEEEEEEEEEE"')
  53. done = True
  54. break
  55.  
  56.  
  57.  
  58.  
  59.  
  60.  
  61.  
  62.  
  63.  
  64.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement