abenassi / Google-Search-API

Python based api for searching google web, images, calc, and currency conversion.
558 stars 217 forks source link

SSL: CERTIFICATE_VERIFY_FAILED using Google Web Search #54

Open stella-lu opened 6 years ago

stella-lu commented 6 years ago

Hi, sorry if this is the wrong place to ask this, but I keep getting the error:

Error accessing: http://www.google.com/search?nl=en&q=hello&start=0&num=10
<urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:833)>

When trying to perform a basic google search using this API.

I've made a Stack Overflow post which hasn't helped so far and I'm not sure what's causing this problem. I assume it must be in the rest of my code. Below is all of my code. Any help is greatly appreciated!

import matplotlib
matplotlib.use('TkAgg') #Stops crashing
from tkinter import * 
import sys
sys.path.append('/Users/Cactus/wiki-word-frequency/Google-Search-API')
from google import google

def find_url(search_term):
    result = google.search(search_term)
    print(result)

if __name__ == "__main__":
    def get_text_button(): #On button click
        find_url(search.get())
    def get_text_enter(search): #On pressing enter/return
        find_url(search.widget.get())

    root =Tk()
    #root.geometry('{}x{}'.format(600, 400))
    #Make layout look good when uncommenting the above line

    title = Label(root, text="Hello tkinter!")
    title.grid(column=0, row=0, columnspan=2)

    label = Label(root, text="Search term: ")
    label.grid(column=0, row=1)

    search = Entry(root, bd=3)
    search.bind("<Return>", get_text_enter)  
    search.grid(column=1, row=1)

    button = Button(root, text="Submit", command=get_text_button)
    button.grid(column=1, row=2, columnspan=1)
    exit = Button(root, text="Exit", command=root.destroy)
    exit.grid(column=0, row=2, columnspan=1)

    root.columnconfigure(0, weight=1)
    root.rowconfigure(0, weight=1)

    root.mainloop()
JacksonArthurClark commented 6 years ago

@stella-lu I've been having the same problem!

stella-lu commented 6 years ago

@KeyKrusher Unfortunately I couldn't figure it out. Maybe someone else will stumble upon this

JacksonArthurClark commented 6 years ago

@stella-lu I certainly hope so!

ghost commented 6 years ago

@stella-lu Just update your ssl certificates - copy and paste into Terminal: (Mac OS X) /Applications/Python\ 3.6/Install\ Certificates.command