Wilson Grant Fisk
Elite Member
- Nov 10, 2012
- 15,677
- 46,846
PHP:
# -*- coding: utf-8 -*-
import requests
import json
# here you include your main terms, this can be as many as you like
terms = ['wine']
# these are just 'variations' which are appended to the start of your 'terms'
variations = ['what * ', 'who * ', 'how * ', 'does * ', 'why * ', 'can * ', 'where * ', 'when * ']
for term in terms:
for variant in variations:
# request api
r=requests.get('http://suggestqueries.google.com/complete/search?client=firefox&q={}{}'.format(variant, term))
# grab returned text loading as json
parsed_json = json.loads(r.text)
# print each parsed item
print parsed_json[0]
for i in parsed_json[1]:
print '- ', i.encode('utf-8', 'ignore')
Read more here: http://www.bronco.co.uk/our-ideas/content-topics/