Code:
import time
import snippets
import ctypes # An included library with Python install.
messages = []
cookies = {
'bb_lastvisit': '',
'bb_lastactivity': '0',
'bb_userid': '',
'bb_password': '',
'IDSZBstack': '',
'bb_sessionhash': '',
'override': 'on',
}
headers = {
'User-Agent': 'Mozilla/5.0 (Windows NT 6.3; WOW64; Trident/7.0; rv:11.0) like Gecko',
'Accept': 'text/html, application/xhtml+xml, */*',
'Accept-Language': 'en-US,en;q=0.5',
# 'Accept-Encoding': 'gzip, deflate',
'Connection': 'keep-alive',
'Referer': 'https://www.szenebox.org/usercp.php',
# Requests sorts cookies= alphabetically
# 'Cookie': 'bb_lastvisit=; bb_lastactivity=0; bb_userid=; bb_password=; IDSZBstack=,bb_sessionhash=; override=on',
'Upgrade-Insecure-Requests': '1',
'Sec-Fetch-Dest': 'document',
'Sec-Fetch-Mode': 'navigate',
'Sec-Fetch-Site': 'same-origin',
'Sec-Fetch-User': '?1',
'DNT': '1',
'Sec-GPC': '1',
'Via': '1.1 180.106.177.92',
'X-Forwarded-For': '180.106.177.92',
# Requests doesn't support trailers
# 'TE': 'trailers',
}
first_run_glb = True
def get_message(first_run):
global first_run_glb
global messages
response = requests.get('https://www.szenebox.org/private.php', cookies=cookies, headers=headers)
if response.status_code == 200:
html = response.text
for message in html.split('</li><li class="blockrow pmbit"'):
id = snippets.find_between(message, ' id="pm_', '">')
if not id in messages:
messages.append(id)
title = snippets.find_between(message, '" class="title">', '</a>')
replied = False
if '<img src="https://www.szenebox.org/images/metro/blue/statusicon/pm_replied.png"' in message:
replied = True
date = snippets.find_between(message, '<label for="pm_imod_checkbox_' + str(id) + '">',
'</span> <input type="checkbox"')
date = date.replace('<span class="time">', "")
print("[" + str(id) + "] Title: [" + str(title) + "] | Date: " + str(date) + "| Replied: " + str(replied))
if first_run == False:
ctypes.windll.user32.MessageBoxW(0, "New Message", title, 1)
first_run_glb = False
while True:
get_message(True)
time.sleep(30)
Tip it
Code:
def find_between( s, first, last ):
try:
start = s.index( first ) + len( first )
end = s.index( last, start )
return s[start:end]
except ValueError:
return ""