-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathboxsearch.py
49 lines (37 loc) · 1.46 KB
/
boxsearch.py
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
import sys
from tkinter import *
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
root =Tk()
ment=StringVar()
def google():
mtext = ment.get() # get the value store in ment
# search
driver = webdriver.Chrome("C:\\Users\\Manu khurana\\Downloads\\chromedriver_win32\\chromedriver.exe")
driver.get("https://www.google.com")
elem = driver.find_element_by_name("q") # name of the search bar
elem.clear()
elem.send_keys(mtext) # this is used to send the data/key
elem.send_keys(Keys.RETURN) # this is used to written the data/key
assert "No result found." not in driver.page_source
mlabel2 = Label(root, text=mtext).pack()
return
def youtube():
mtext = ment.get() # get the value store in ment
#search
driver=webdriver.Chrome("C:\\Users\\Manu khurana\\Downloads\\chromedriver_win32\\chromedriver.exe")
driver.get("https://www.youtube.com")
elem = driver.find_element_by_name("search_query")
elem.clear()
elem.send_keys(mtext)
elem.send_keys(Keys.RETURN)
assert "NO result found"
mlabel2 = Label(root, text=mtext).pack()
return
root.geometry('400x400')
root.title("MY personal search")
mlabel=Label(root,text="my label" ).pack()
mEntry=Entry(root,textvariable=ment).pack()
mbutton=Button(root,text="google search" ,command=google).pack()
mbutton=Button(root,text="youtube search" ,command=youtube).pack()
mainloop()