def calc_generator(stri): browser = webdriver.Chrome(str(get_config_information())) s = "https://www.google.com" browser.get(s) strl = stri[6:] time.sleep(1) sele = browser.find_element_by_id('lst-ib') sele.send_keys(str(strl)) sele.send_keys(Keys.ENTER) time.sleep(2) myele = browser.find_element_by_id('cwos') ans = myele.text browser.quit() return ans
def define_generator(stri): browser = webdriver.Chrome(str(get_config_information())) s = "https://www.google.com" browser.get(s) strl = stri[8:] time.sleep(1) sele = browser.find_element_by_id('lst-ib') sele.send_keys("define " + str(strl)) sele.send_keys(Keys.ENTER) time.sleep(2) strr = " " sres = browser.find_elements_by_xpath("//*[@data-dobid='dfn']/span") for s in sres: strr += s.text browser.quit() return (strr)
def weather_generator(stri): browser = webdriver.Chrome(str(get_config_information())) strl = stri[9:] s = "https://www.google.com" browser.get(s) time.sleep(1) sele = browser.find_element_by_id('lst-ib') sele.send_keys("weather " + str(strl)) sele.send_keys(Keys.ENTER) time.sleep(2) strr = " " myele = browser.find_element_by_id('wob_tm') mystring = str(myele.text)+" ℃" browser.quit() return mystring
def youtube_generator(stri): browser = webdriver.Chrome(str(get_config_information())) strl = stri[8:] s = "https://www.google.com" browser.get(s) time.sleep(1) sele = browser.find_element_by_id('lst-ib') sele.send_keys(str(strl)) sele.send_keys(Keys.ENTER) tab_change = browser.find_element_by_xpath("//a[text()='Videos']") tab_change.click() stlink = browser.find_elements_by_xpath("//*[@class='r']/a") myele = stlink[0].get_attribute("href") browser.quit() return (myele)
def lyrics_generator(stri): browser = webdriver.Chrome(str(get_config_information())) s = "https://www.musixmatch.com/" browser.get(s) mystr = stri[8:] # print(mystr) time.sleep(10) sbtn = browser.find_element_by_xpath( '//*[@id="site"]/div/div[1]/div/main/div/div[1]/div[2]/div/div/div/div[1]/div/span/span/span/form/div/div[1]/input' ) sbtn.send_keys(str(mystr)) time.sleep(8) mysearch = browser.find_element_by_xpath( '//*[@id="site"]/div/div[1]/div/main/div/div[1]/div[2]/div/div/div/div[1]/div/span/span/span[2]/div/div/div/div[1]/div[2]/div/ul/li/a/div[2]/h2' ) mysearch.click() time.sleep(2) ele = browser.find_elements_by_class_name('mxm-lyrics__content ') strl = " " for e in ele: strl += e.text browser.quit() return strl
import quote import joke import flirt import os import xml.etree.ElementTree as ET import random import mytime import lyrics import definine import weather import youtubee import news import calc from util import get_config_information browser = webdriver.Chrome(str(get_config_information())) s = "https://web.whatsapp.com/" browser.get(s) time.sleep(5) browser.find_element_by_xpath( '//*[@id="app"]/div/div/div[2]/div/div[3]/label/input').click() time.sleep(15) commands = [ "/quote", "/funfact", "/time", "/joke", "/calc", "/conv", "/lyrics", "/define", "/news", "/weather", "/wikipedia" ]
def news_generator(stri): browser = webdriver.Chrome(str(get_config_information())) s = "https://news.google.com" elem = [] browser.get(s) if (len(stri) == 5): ele = browser.find_elements_by_xpath( "//a[@role='heading'][@aria-level='2']") for e in ele: if (len(e.text) != 0): elem.append(e.text) browser.quit() return elem elif (str(stri[6:]) == 'technology'): btntech = browser.find_element_by_xpath("//a[text()='Technology']") btntech.click() time.sleep(3) ele = browser.find_elements_by_xpath( "//a[@role='heading'][@aria-level='2']") for e in ele: if (len(e.text) != 0): elem.append(e.text) browser.quit() return elem elif (str(stri[6:]) == 'world'): btntech = browser.find_element_by_xpath("//a[text()='World']") btntech.click() time.sleep(3) ele = browser.find_elements_by_xpath( "//a[@role='heading'][@aria-level='2']") for e in ele: if (len(e.text) != 0): elem.append(e.text) browser.quit() return elem elif (str(stri[6:]) == 'business'): btntech = browser.find_element_by_xpath("//a[text()='Business']") btntech.click() time.sleep(3) ele = browser.find_elements_by_xpath( "//a[@role='heading'][@aria-level='2']") for e in ele: if (len(e.text) != 0): elem.append(e.text) browser.quit() return elem elif (str(stri[6:]) == 'entertainment'): btntech = browser.find_element_by_xpath("//a[text()='World']") btntech.click() time.sleep(3) ele = browser.find_elements_by_xpath( "//a[@role='Entertainment'][@aria-level='2']") for e in ele: if (len(e.text) != 0): elem.append(e.text) browser.quit() return elem elif (str(stri[6:]) == 'sports'): btntech = browser.find_element_by_xpath("//a[text()='Sports']") btntech.click() time.sleep(3) ele = browser.find_elements_by_xpath( "//a[@role='heading'][@aria-level='2']") for e in ele: if (len(e.text) != 0): elem.append(e.text) browser.quit() return elem elif (str(stri[6:]) == 'science'): btntech = browser.find_element_by_xpath("//a[text()='Science']") btntech.click() time.sleep(3) ele = browser.find_elements_by_xpath( "//a[@role='heading'][@aria-level='2']") for e in ele: if (len(e.text) != 0): elem.append(e.text) browser.quit() return elem elif (str(stri[6:]) == 'health'): btntech = browser.find_element_by_xpath("//a[text()='Health']") btntech.click() time.sleep(3) ele = browser.find_elements_by_xpath( "//a[@role='heading'][@aria-level='2']") for e in ele: if (len(e.text) != 0): elem.append(e.text) browser.quit() return elem elif (str(stri[6:]) == 'local'): btntech = browser.find_element_by_xpath("//div[text()='Local']") btntech.click() time.sleep(3) ele = browser.find_elements_by_xpath( "//a[@role='heading'][@aria-level='2']") for e in ele: if (len(e.text) != 0): elem.append(e.text) browser.quit() return elem