コード例 #1
0
async def main():
    storage_manager = get_storage_manager('redis')
    async with GoogleSearch() as google_search:
        bot = Bot(command_prefix='!')
        initialize_bot(bot, storage_manager, google_search)
        try:
            await bot.start(settings.TOKEN)
        finally:
            await bot.close()
コード例 #2
0
 def __init__(self):
     self.__crawler = Crawler()
     self.__cleaner = Cleaner()
     self.__file_manager = FileManager()
     self.__search_engine = GoogleSearch(config.SEARCH_TOPIC,
                                         config.MAX_ITEM,
                                         config.NUMBER_OF_RESULTS_PER_PAGE,
                                         config.PAUSE_BTW_REQUEST)
     self.__csf_manager = CSFManager()
コード例 #3
0
def search(a):
  try:
    gs = GoogleSearch(a)
    gs.results_per_page = 100
    results = gs.get_results()
    for res in results:
      print res.title.encode("utf8")
      print res.desc.encode("utf8")
      print res.url.encode("utf8")
      print
  except SearchError, e:
    print "Search failed:"
コード例 #4
0
def find(food_name):
	try:
	  print "Got" + str(food_name)
	  gs = GoogleSearch(food_name)
	  gs.results_per_page = 10
	  results = gs.get_results()
	  #print results
	  lines = []
	  for res in results:
	    lines.append(res.encode("utf8"))
	  
	  return lines
	except SearchError, e:
	  print "Search failed: %s" % e
コード例 #5
0
def GetSearchResults(query=None, type=None, exact=False):

    if (type == "movies"):
        # This a google search. The -tv will ommit all TV shows.
        search = 'intitle:%s -"Episode List" -"Series Rating"' % (query)
    else:
        search = 'allintitle:%s "Episode List"' % (query)

    gs = GoogleSearch(search)
    gs.results_per_page = 25
    gs.page = 0
    results = gs.get_results() + gs.get_results()
    items = []

    for res in results:

        name = re.sub(
            '(<em>|</em>|<a>|</a>|DivX|-|icefilms(\.info)?|<b>\.\.\.</b>|Episode List|links)',
            '', res.title.encode('utf8')).strip()

        url = res.url
        video_url = re.search("icefilms\.info(/.*)", url).group(1)

        res = {}

        res['type'] = type
        res['title'] = name

        match = re.search("(.*)\((\d*)\)", res['title'])

        if (match):
            res['title'] = match.group(1).strip()
            res['year'] = int(match.group(2).strip())

        res['id'] = video_url

        items.append(res)

    return items
コード例 #6
0
import argparse
import logging
import os
import sys

from search import GoogleSearch
import settings

logging.basicConfig(stream=sys.stdout, level=logging.INFO)

if __name__ == '__main__':
    parser = argparse.ArgumentParser()
    parser.add_argument('term', help='search term')

    if not os.path.exists(settings.STORAGE_ROOT):
        try:
            os.makedirs(settings.STORAGE_ROOT)
        except OSError:
            logging.error('Unable to create storage folder %s' %
                          settings.STORAGE_ROOT)
            sys.exit(1)

    GoogleSearch(parser.parse_args().term).search()
コード例 #7
0
#!/usr/bin/python
#
# This program does a Google search for "quick and dirty" and returns
# 50 results.
#

from search import GoogleSearch, SearchError
try:
  gs = GoogleSearch("quick and dirty")
  gs.results_per_page = 50
  results = gs.get_results()
  for res in results:
    print res.title.encode('utf8')
    print res.desc.encode('utf8')
    print res.url.encode('utf8')
    print
except SearchError, e:
  print "Search failed: %s" % e