-1

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()
Alex_P
  • 2,580
  • 3
  • 22
  • 37
HugoS
  • 105
  • 11
  • Please provide more information. What do you mean by 'extracts a word into a keyword in chrome'? Which hyperlink are you talking about? Where does the word come from? Do you already tried some code? If so, please add it to your question. – Alex_P Nov 11 '18 at 15:12
  • I have made a textbox that i can write in, and i have a button. When i press the button, i want the text in the textbox to be implemented into chrome as a keyword. I am trying to make a bot for https://shop.palaceskateboards.com/, written in python. And i want a keyword function that searches for a specific clothing piece. – HugoS Nov 11 '18 at 15:14
  • 2
    @HugoSigurdson when adding detail to your question, add it to the *body* of the question; comments aren't the correct place, and comments are much more limited in length and formatting – landru27 Nov 11 '18 at 18:52

1 Answers1

0

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.

Alex_P
  • 2,580
  • 3
  • 22
  • 37
  • It crashes for me everytime i try and write something. And it does not search for a specific word in an html webpage. – HugoS Nov 11 '18 at 15:44
  • This is what i have written, https://pastebin.com/ebZxMGAk. Some of it is in Swedish. – HugoS Nov 11 '18 at 15:50
  • No, it does not search for a word on a website. It takes a word you enter in your editor and searches the word in google. Did you try my code and it crashes for you? – Alex_P Nov 11 '18 at 15:51
  • But i want a textbox that searches for a specific word on https://shop.palaceskateboards.com/, then enters that link containing that word. – HugoS Nov 11 '18 at 15:52
  • It still crashes for me. And it now works somewhat, but i want it to search inside the element of the html doc. – HugoS Nov 11 '18 at 16:09
  • And i have to paste what i want to search for in cmd now. It does not search when i put the keyword in the box and press the button. – HugoS Nov 11 '18 at 16:17
  • Can you please provide an update version of your code? – Alex_P Nov 11 '18 at 16:19
  • Do you have access to the html doc or database to look there directly? – Alex_P Nov 11 '18 at 16:33
  • I am very new to python as you notice. No i dont. But i might be able to specify the item”keyword” via Inspect Element on chrome? Might not even work in python? – HugoS Nov 11 '18 at 16:38