Jump to content

Input Needed: Dictionary Creation


bazju
 Share

Recommended Posts

Google API is very simple in it's basic form. The code to pull results form google is below.

import urllib2
import json

key = raw_input('Enter Authorization Key: ')

url = 'https://www.googleapis.com/customsearch/v1?key='

cse = '&cx=002552950702745516136:2s9vh3zvyni&q='

search = raw_input("Search word: ")

data = urllib2.urlopen(url+key+cse+search)
data = json.load(data)

for result in data['items']:
    print result['snippet']
    print result['link']
    #There are many other things you can choose to print as well from the dictionary.



print linx

You need to have a google account and create a Google API key to use the search.

cse can be any custom search engine that you want. '&cx=YOUR SEARCH ENGINE&q='

Edited by bazju
Link to comment
Share on other sites

Yea looks like something similar to it has been done. I'm hoping to add some extra features. Either way I'm mostly doing this as practice to get better at Python. Still looking for ideas if anyone has noticed something missing from the current options in this area.

Link to comment
Share on other sites

  • 1 month later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...