Use Python to Access Google Insights API
Posted in Web Development - No Comments »
Google Insights provides a lot of interesting information to see search trends over time. It provides information like general search volume, related keywords, top countries and much more.
I was working on a project that needed access to this data, so I developed a simple python module for querying a given keyword. I’m releasing it here because I thought others may find this data useful.
Here are some examples on how you would use this plugin:
>>> import insights, pprint
>>> oInsights = insights.Insights('guitar strings')
>>> oInsights.section('trend')
{'2004-01-04': '74',
'2004-01-11': '71',
'2004-01-18': '82',
'2004-01-25': '74',
...
...
}
>>> pprint.pprint( oInsights.section('related') )
{'12 strings guitar': '10',
'7 strings guitar': '5',
'acoustic guitar': '90',
'acoustic guitar strings': '85',
...
>>> pprint.pprint( oInsights.section('cities') )
{'Atlanta (United States)': '81',
'Birmingham (United Kingdom)': '97',
'Chicago (United States)': '90',
'London (United Kingdom)': '88',
'Los Angeles (United States)': '100',
...
>>> pprint.pprint( oInsights.section('rising') )
{'7 strings guitar': '+20%',
'classic guitar strings': '+20% ',
'dr guitar strings': '+40% ',
'dr strings': '+30% ',
...
Its important to note this module only works with one keyword. It would be fairly simple to get it working with multiple keywords, but my project only required one.
Also, I’m releasing this under Beerware License.
That’s all there is to it. Any questions/bugs please submit in comments.