-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrlExchange_searchengine.py
More file actions
69 lines (63 loc) · 2.2 KB
/
rlExchange_searchengine.py
File metadata and controls
69 lines (63 loc) · 2.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# Searches rocketleagueexchange for desired items, outputs to and opens html page.
from __future__ import print_function
import praw
import webbrowser
def reddit_auth():
global reddit, subreddit
reddit = praw.Reddit(client_id="", client_secret="",
password='', user_agent='',
username='')
subreddit = reddit.subreddit('RocketLeagueExchange')
def get_input():
global uFlair, fQuery, uLimit, uSort, uTime, uTitle
gFlair=input("Enter PC, PS4, or Xbox: ") or "PC"
uFlair="[" + gFlair + "]"
uQuery=input("Enter desired item. e.g. Hypernova: ") or "Photon"
fQuery=(uFlair + " " + uQuery)
uLimit=input("How many results? e.g. 10: ") or 10
uSort=input("Sort by relevance, hot, top, new, or comments?: ") or "relevance"
uTime=input("Seach post from the last hour, day, week, month, or year?: ") or "hour"
uTitle="Searching for post(s) containing: \"" + fQuery + "\" posted in the last " + uTime + " sorted by " + uSort
def create_htm():
global filepath, outputFile
filepath="/Scripts/Python/out.html"
outputFile=open(filepath, 'w', errors='ignore')
sTags='''<html>
<head>'''+ uTitle.upper() +'''</head>
<body><p>'''
print (sTags, file=outputFile)
def close_htm():
eTags='''</p></body>
</html>'''
print (eTags, file=outputFile)
def add_urllist():
print("<a href=" + submission.url + ">" + submission.title + "</a>", sep='', end='<br>', file=outputFile)
def do_search():
for submission in subreddit.search(fQuery, sort=uSort, limit=int(uLimit), time_filter=uTime.lower()):
print("<a href=" + submission.url + ">" + submission.title + "</a>", sep='', end='<br>', file=outputFile)
def open_htm():
webbrowser.open(filepath)
def email_self(fFile): # Doesn't work, email is blank
import smtplib
from email.mime.text import MIMEText
gmail_user=""
gmail_pwd=""
fp = open(fFile, 'r')
msg = MIMEText(fp.read(), _subtype="html")
fp.close()
msg['Subject'] = "RLE Trades"
msg['From'] = ""
msg['TO'] = ""
s = smtplib.SMTP_SSL('smtp.gmail.com', 465)
s.ehlo()
s.starttls
s.login(gmail_user, gmail_pwd)
s.sendmail("to", "from", msg.as_string())
s.close
reddit_auth()
get_input()
create_htm()
do_search()
close_htm()
# email_self(filepath)
open_htm()