PROXY  WHOIS  RQUOTE  TEXTS  SOFT  FOREX  BBOARD
 Music  Philosophy  Code  Literature  Russian

= ROOT|Technical|LinuxGazette|issue107.txt =

page 8 of 66




   If people write in with similar problems installing from the small Gentoo
   ISO  images, we could do worse than point them in the direction of the
   revised image. Here's a link to such on one of the mirrors:

     [100]http://lug.mtu.edu/gentoo/experimental/x86/livecd/x86

   Not every mirror carries the "experimental" part of the tree, here's a link
   to the list of mirrors:

     [101]http://www.gentoo.org/main/en/mirrors.xml

   FYI,

   .brian (who still hasn't found a way to add custom X-Headers to Thunderbird)
            ____________________________________________________

search google from command line

   Raj Shekhar ([102]rajshekhar from hotpop.com)

   Hello all,

   This is a ugly hack that I am using to search the google from command line.
   Any decent Python programmer would be able to make it much better. You need
   to have Pygoogle ([103]http://pygoogle.sourceforge.net) module installed. In
   its unaltered form, the script will require Python2.3 to run. However, if
   you remove the #--ugly hack part (see the comments in the code), it will run
   with Python2.2 too.

#!/usr/bin/python2.3
import google,sys,codecs
from sgmllib import SGMLParser

# HTML Stripper class to strip out html from the google search
# returned.  shamelessly copy pasted from
# http://mail.python.org/pipermail/tutor/2002-September/017573.html

class HTMLStripper(SGMLParser):
     def __init__(self):
         SGMLParser.__init__(self)
         self._text = []

     def handle_data(self, data):
         self._text.append(data)

     def read_text(self):
         return ".join(self._text)


def strip_html(text):
     stripper = HTMLStripper()
     stripper.feed(text)
     return stripper.read_text()

print "Searching the World Live Web "

google.setLicense('your google key') # must get your own key from
http://www.google.com/apis/ -> free but requires registration
n_show_results = 10 #change the number of search results that are shown
from here

codecs.register_error('xml', codecs.xmlcharrefreplace_errors)

search_str = ""
for i in range(1,len(sys.argv)):
     search_str = search_str + " " + sys.argv[i]

print "Searching for " ,search_str

data = google.doGoogleSearch(search_str,0,n_show_results)

print 'Search took %f time and I found a total of %d results\n' % (data.meta.se
archTime, data.meta.estimatedTotalResultsCount)

for result in data.results:

     # if you are going to call this script from within emacs, replace
     # this part with the code within the #begin hack -- #end hack code

     print 'Title\t:', strip_html(result.title)
     print 'URL\t:', result.URL
     print

     #-- begin hack

     # if you want to call this script from within emacs, then you have
     #to put in this ugly hack. Other wise emacs will stop with an
     #error message "UnicodeEncodeError: 'ascii' codec can't encode
     #character u'\xfc' in position 1: ordinal not in range(128)"

     # see  http://www.informit.com/articles/article.asp?p=31272&seqNum=5
     # to know why this ugly hack is needed

##     temp = result.title
##     in_tuple=codecs.getencoder('ASCII')(temp, 'xml')
##     in_str = str(in_tuple)
##     print 'Title\t:', strip_html(in_str)
##     print 'URL\t:', result.URL
##     print
=8=

1|2|3|4|5|6|7| < PREV = PAGE 8 = NEXT > |9|10|11|12|13|14|15|16|17.66

UP TO ROOT | UP TO DIR | TO FIRST PAGE

Google
 


E-mail Facebook Google Digg del.icio.us BlinkList Fark Furl Ma.gnolia Netscape NewsVine Reddit Slashdot Spurl StumbleUpon Technorati YahooMyWeb LiveJournal Blogmarks TwitThis Live News2.ru BobrDobr.ru Memori.ru MoeMesto.ru

0.0121081 wallclock secs ( 0.01 usr + 0.00 sys = 0.01 CPU)