Advertisement
Guest User

Untitled

a guest
Nov 17th, 2017
385
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.98 KB | None | 0 0
  1. import json
  2. import requests
  3. from lxml import html
  4. import socket
  5.  
  6. #we set up the URLs we're gonna need
  7. URL_AUTH = "https://www.saltybet.com/authenticate?signin=1"
  8. URL_STATS = "http://www.saltybet.com/ajax_get_stats.php"
  9. URL_MAIN = "http://www.saltybet.com"
  10.  
  11. #we set up the twitch stuff
  12. HOST = "irc.twitch.tv"
  13. PORT = 6667
  14. NICK = "casey666666"
  15. PASS = 'oauth:6aqdwxmv51wt99p176cpto9wg87cqt'
  16.  
  17. #we probably won't ever need the bot to send a message but whatever here it is
  18. def send_message(message):
  19. s.send(bytes("PRIVMSG #" + NICK + " :" + message + "\r\n", "UTF-8"))
  20.  
  21. s = socket.socket()
  22. s.connect((HOST, PORT))
  23. s.send(bytes("PASS " + PASS + "\r\n", "UTF-8"))
  24. s.send(bytes("NICK " + NICK + "\r\n", "UTF-8"))
  25. s.send(bytes("JOIN #saltybet" + " \r\n", "UTF-8"))
  26.  
  27. while True:
  28. line = str(s.recv(1024))
  29. if "End of /NAMES list" in line:
  30. break
  31.  
  32. while True:
  33. for line in str(s.recv(1024)).split('\\r\\n'):
  34. parts = line.split(':')
  35. if len(parts) < 3:
  36. continue
  37.  
  38. if "QUIT" not in parts[1] and "JOIN" not in parts[1] and "PART" not in parts[1]:
  39. message = parts[2][:len(parts[2])]
  40.  
  41. usernamesplit = parts[1].split("!")
  42. username = usernamesplit[0]
  43.  
  44. print(username + ": " + message)
  45.  
  46. #open a session and authenticate to saltybet
  47. session_requests = requests.session()
  48.  
  49. result = session_requests.get(URL_AUTH)
  50. tree = html.fromstring(result.text)
  51. signin = list(set(tree.xpath("//input[@name='authenticate']/@value")))[0]
  52.  
  53. AUTH = {"email": "hsafwcaseycrane@gmail.com", "pword": "e8EgNk8U", "authenticate": signin}
  54.  
  55. result = session_requests.post(URL_AUTH, data = AUTH, headers = dict(referer = URL_AUTH))
  56.  
  57. #now we start phase one of data mining, the illuminati stats. we scrape this right after bets are open and return it as a JSON object.
  58. def illuminati_scrape():
  59. sb = session_requests.get(URL_STATS, headers = dict(referer = URL_STATS))
  60. return sb.json();
  61.  
  62. print(illuminati_scrape())
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement