Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import json
- import requests
- from lxml import html
- import socket
- #we set up the URLs we're gonna need
- URL_AUTH = "https://www.saltybet.com/authenticate?signin=1"
- URL_STATS = "http://www.saltybet.com/ajax_get_stats.php"
- URL_MAIN = "http://www.saltybet.com"
- #we set up the twitch stuff
- HOST = "irc.twitch.tv"
- PORT = 6667
- NICK = "casey666666"
- PASS = 'oauth:6aqdwxmv51wt99p176cpto9wg87cqt'
- #we probably won't ever need the bot to send a message but whatever here it is
- def send_message(message):
- s.send(bytes("PRIVMSG #" + NICK + " :" + message + "\r\n", "UTF-8"))
- s = socket.socket()
- s.connect((HOST, PORT))
- s.send(bytes("PASS " + PASS + "\r\n", "UTF-8"))
- s.send(bytes("NICK " + NICK + "\r\n", "UTF-8"))
- s.send(bytes("JOIN #saltybet" + " \r\n", "UTF-8"))
- while True:
- line = str(s.recv(1024))
- if "End of /NAMES list" in line:
- break
- while True:
- for line in str(s.recv(1024)).split('\\r\\n'):
- parts = line.split(':')
- if len(parts) < 3:
- continue
- if "QUIT" not in parts[1] and "JOIN" not in parts[1] and "PART" not in parts[1]:
- message = parts[2][:len(parts[2])]
- usernamesplit = parts[1].split("!")
- username = usernamesplit[0]
- print(username + ": " + message)
- #open a session and authenticate to saltybet
- session_requests = requests.session()
- result = session_requests.get(URL_AUTH)
- tree = html.fromstring(result.text)
- signin = list(set(tree.xpath("//input[@name='authenticate']/@value")))[0]
- AUTH = {"email": "hsafwcaseycrane@gmail.com", "pword": "e8EgNk8U", "authenticate": signin}
- result = session_requests.post(URL_AUTH, data = AUTH, headers = dict(referer = URL_AUTH))
- #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.
- def illuminati_scrape():
- sb = session_requests.get(URL_STATS, headers = dict(referer = URL_STATS))
- return sb.json();
- print(illuminati_scrape())
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement