summaryrefslogtreecommitdiffstats
path: root/GoogleStats.py
blob: 1cf889e4af46c7b3ec8f10f5dc0ba16ca4a9bec6 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
# -*- coding: iso-8859-1 -*-
#!/usr/bin/env python

from urllib2 import build_opener
from urllib import quote_plus
from re import findall
		
def blogSearchMonthResultCount(keyword):
	opener = build_opener()
	opener.addheaders = [('User-agent', 'Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1)')]
	resultsScrape = findall('<div id=resultStats>(?:About ){0,1}([0-9,]+) result[s]{0,1}<nobr>', opener.open("http://www.google.com/search?q=%s&safe=off&tbs=blg:1,qdr:m" % quote_plus(keyword)).read())
	if len(resultsScrape) == 0:
		return 0
	return int(resultsScrape[0].replace(",", ""))