Archive for February, 2010

Google Search with Python 3 and Tkinter

Monday, 02 February 2010

Google Search with Python and Tkinter;

# http://m-eken.com
# python 3
#google Searcher
import tkinter,urllib.request,urllib.parse,urllib.error
from tkinter import *
from tkinter import ttk

class window:
    def __init__(self,root):
        self.root=root
        self.root.title("Google Searcher")
        ttk.Frame(self.root, width=500,height=250).pack()
        self.init_widgets()

    def init_widgets(self):
        ttk.Button(self.root, command=self.insert_text,text="Gooo",width="10").place(x=400,y=10)
        self.txt=tkinter.Text(self.root,width="52",height="10", font=12)
        self.txt.place(x=10,y=40)
        self.searchWord=tkinter.Text(self.root,width="42",height="1", font=12)
        self.searchWord.insert(tkinter.INSERT,"google search with python 3 tkinter")
        self.searchWord.place(x=10,y=15)

    def insert_text(self):
        GWord=self.searchWord.get(1.0,END)
        url="http://www.google.com/search?hl=en&q="+"+".join(GWord.split())
        req=urllib.request.Request(url)
        req.add_header("User-Agent","Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US) AppleWebKit/525.13 (KHTML, like Gecko) Chrome/0.2.149.29 Safari/525.13")
        GWord= urllib.request.urlopen(req).read()
        self.txt.insert(tkinter.INSERT,  GWord)

if __name__=="__main__":
    root=tkinter.Tk()
    window(root)
    root.mainloop()

Python 3 Google Search Sample

Wednesday, 02 February 2010

Sample Google Search Python code
import urllib.request,urllib.parse,urllib.error
print("Google Searcher --- www.m-eken.com v.P5012")
while input("s: Search. q: Quit #: ")=="s":
GWord=input("#: ")
url="http://www.google.com/search?hl=en&q="+"+".join(GWord.split())
print(GWord+"\nsearching... ")
req=urllib.request.Request(url)
req.add_header("User-Agent","Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US) AppleWebKit/525.13 (KHTML,     like Gecko) Chrome/0.2.149.29 Safari/525.13")
print( urllib.request.urlopen(req).read())


Yonca Evcimik – Vurula Vurula

Wednesday, 02 February 2010


Cem Karaca – Herkes Gibisin

Tuesday, 02 February 2010


Tanju Okan – Koy Koy Koy

Monday, 02 February 2010


Düş Sokağı Sakinleri – İstanbul Akşamlarım

Monday, 02 February 2010


  • "I am a dreamer. Seriously, I'm living on another planet."
  • Lütfü Hoca

  • Categories

  • Archives