Google from command line
#!/usr/bin/env python
__author__ = "Tom Luo"
__version__ = "$Revision 0.1 $"
__date__ ="$Date: 2012/01/04 11:11PM MST$"
import os, urllib, sys
import re
def f(x):
return x.find('Cached') < 0
filename = 'http://www.google.com/search?' + urllib.urlencode({'q': ' '.join(sys.argv[1:]) })
fobj= os.popen("lynx -dump -width=120 %s" % filename)
output = fobj.read()
fobj.close()
start = output.find("Web Results 1 - 10")
end = output.find("Searches related to:")
lines = output[start:end]
lines = reversed(re.split('\[\d+\]',lines))
lines = filter(f,lines)
print '.'.join(lines)
chmod +x g.sh g.sh oracle
No comments yet