Skip to content

Instantly share code, notes, and snippets.

@StickmanNinja
Created September 6, 2018 21:23
Show Gist options
  • Save StickmanNinja/c162c226d0f94951d24df83e9e8fab2f to your computer and use it in GitHub Desktop.
Save StickmanNinja/c162c226d0f94951d24df83e9e8fab2f to your computer and use it in GitHub Desktop.
A simple little Python notification system that looks for Ted Cruz polling data on Google. If the data exists, then the script notifies me via text message
from bs4 import BeautifulSoup
from six.moves import urllib
from selenium import webdriver
from selenium.webdriver.firefox.options import Options
import requests
from selenium import webdriver
from selenium.common.exceptions import NoSuchElementException
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support.ui import Select
def SendText(yourname, message, recipientPhoneNumber):
try:
driver = webdriver.Firefox(executable_path=r'/usr/local/bin/geckodriver')
driver.get("http://www.24sms.net/")
driver.find_element_by_name('SendFrom').send_keys(str(name))
driver.find_element_by_name('SendTo').send_keys(str(recipientPhoneNumber))
driver.find_element_by_name("Msg").send_keys(str(message))
driver.find_element_by_xpath("//input[@type='submit']").click()
driver.close()
driver.quit()
return True
except:
return False
def checkForPoll():
foxnewslist = []
search = 'https://www.google.com/search?biw=1280&bih=726&tbm=nws&ei=UJiRW_XwC8nSsAWit4G4Ag&q=ted+cruz&oq=ted+cruz&gs_l=psy-ab.3..0l10.39796.40467.0.40677.6.6.0.0.0.0.106.413.5j1.6.0....0...1c.1.64.psy-ab..0.6.412....0.ZEuDeWIsHw8'
r = requests.get(search)
data = r.text
soup = BeautifulSoup(data, 'lxml')
for i in soup:
if "poll" in soup:
SendText("Ted Cruz Poll Finder", "A new Ted Cruz poll has been found.", "[MY PHONE NUMBER]")
else:
print "No poll found."
print str(i)
checkForPoll()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment