I am trying to make a textbox that extracts a word into a keyword in chrome. When i press a button the keyword in the textbox gets implemented into chrome and if that keyword is found, it then goes into that hyperlink.
The code is so far:
from tkinter import *
from tkinter.messagebox import *
import webbrowser
root = Tk()
url = 'https://shop.palaceskateboards.com/'
frame = Frame(root)
frame.pack()
def OpenUrl():
webbrowser.open_new(url)
button = Button(frame, text="Start", command=OpenUrl)
button.pack()
root.mainloop()
Try this code. For me it works when I entered 'python'.
from tkinter import *
import webbrowser
def google(event):
address = "http://www.google.com/#q="
word = input("What do you want to search for? ")
search = address + word
webbrowser.open_new(search)
root = Tk()
textbox = Entry(root)
button = Button(root, text="Click")
button.bind("<Button-1>", google)
textbox.pack()
button.pack()
root.mainloop()
For the next time, please provide your code even if it is only the creation of your tkinter widgets.
***** Edit *****
For html searching, try to use the following code:
def checkForWord():
r = requests.get("http://example.com/somepage.html")
return "myWord" in r.text
If the html lookup works, incorporate both parts and replace the word variable with the checkForWord function.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.