This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import smtplib | |
def send_mail(subject, body, reciever): | |
server = smtplib.SMTP('smtp.gmail.com', 587) | |
server.ehlo() | |
server.starttls() | |
server.ehlo() | |
server.login(config.email, config.password) | |
msg = f"Subject: {subject}\n\n{body}" | |
server.sendmail(config.email, reciever, msg) | |
server.quit() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sports | |
# Sports function | |
def scores(query): | |
try: | |
result = [] | |
all_matches = sports.all_matches() | |
keys = list(all_matches.keys()) | |
for j in range(len(keys)): | |
temp = all_matches[keys[j]] | |
matches = [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Test Movie methods | |
query = "The Karate Kid" | |
moviesDB = imdb.IMDb() | |
movies = moviesDB.search_movie(find_imdb(query)) | |
id = movies[0].getID() | |
score = rotten_tomatoes_score(find_imdb(query)) | |
movie = moviesDB.get_movie(id) | |
title = movie['title'] | |
year = movie['year'] | |
rating = movie['rating'] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Rotten Tomatoes Score | |
def rotten_tomatoes_score(query): | |
try: | |
query += query + " Rotten Tomatoes" | |
URL = google_query(query)[0] | |
page = requests.get(URL, headers=headers) | |
soup = BeautifulSoup(page.content, 'html.parser') | |
res = soup.find(class_='mop-ratings-wrap__percentage').get_text() | |
check = res.split(' ') | |
for i in check: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import imdb | |
# Find IMDB | |
def find_imdb(query): | |
try: | |
query += ' IMDB' | |
URL = google_query(query)[0] | |
page = requests.get(URL, headers=headers) | |
html_content = page.text | |
soup = BeautifulSoup(html_content, 'lxml') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import config | |
# Check Weather | |
def weather(latitude, longitude): | |
try: | |
api_key = config.api_key | |
base_url = 'http://api.openweathermap.org/data/2.5/weather?' | |
complete_url = base_url + "lat=" + \ | |
str(latitude) + "&lon=" + str(longitude) + "&appid=" + api_key | |
response = requests.get(complete_url) | |
x = response.json() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Get location | |
def get_location(): | |
try: | |
URL = 'https://iplocation.com/' | |
page = requests.get(URL, headers=headers) | |
soup = BeautifulSoup(page.content, 'html.parser') | |
city = soup.find(class_='city').get_text() | |
country = soup.find(class_='country_name').get_text() | |
latitude = soup.find(class_='lat').get_text() | |
longitude = soup.find(class_='lng').get_text() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Import Search module | |
from googlesearch import search | |
# Make Google Query | |
def google_query(query): | |
link = [] | |
for j in search(query, tld="ca", num=10, stop=10, pause=2): | |
link.append(j) | |
return link |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Import libraries | |
from bs4 import BeautifulSoup | |
import requests | |
# Configure Browser Header and URL | |
headers = { | |
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.105 Safari/537.36'} | |
URL = '' | |
# Check Price of stock |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import datetime | |
# Greeting Function | |
def greet(): | |
hour = int(datetime.datetime.now().hour) | |
if hour >= 0 and hour <= 12: | |
speak("Good Morning!") | |
print("Good Morning!") | |
elif hour > 12 and hour < 16: | |
speak("Good Afternoon!") |