def search_web(self, term): ''' searches web by yahoo DEPRECATED ''' term = term.strip() lang = None page = 1 if term: (term, page) = self.extract_page_param(term) if term.find('#')+1: term, lang = term.split('#',1) term = term.strip() if term == '': return "Please specify your search term" # handle single and double quotes term = term.replace("'",'"') query = 'select title,url,date,abstract ' query += 'from search.web(%d,%d) where query=\'%s\' ' % (self._get_offset(page), self.result_limit, term) if lang: query += ' AND region="%s" AND lang="%s" ' % (lang, lang) yql_api = YQLApi() response = yql_api.request(query=query) hits = self._extract_hits(response) title = 'Searching the web for %s\n' % term return self.render(data=hits, title=title)
def search(self, term): ''' searches web by yahoo ''' term = term.strip() what = 'artist' page = 1 if term: (term, page) = self.extract_page_param(term) if term.find('#')+1: term, what = term.split('#',1) term = term.strip() if term == '': return "Please specify your search term" # handle single and double quotes term = term.replace("'",'"') query = 'select * ' query += 'from music.%s.search(%d,%d) where keyword=\'%s\' ' % (what, self._get_offset(page), self.result_limit, term) yql_api = YQLApi() response = yql_api.request(query=query) title = 'Searching %ss for %s\n' % (what, term) return self.render(data=response, title=title)
def search_blip(self, term): ''' searches for blips on blip.fm ''' term = term.strip() if term == '': return "Please specify your search term" (term, page) = self.extract_page_param(term) yterm = 'intitle:"%s" site:blip.fm inurl:profile -intitle:"Props given" -intitle:"Favourite DJs" \ -intitle:"Blip.fm %s"' % (term, term) query = 'select title,url from search.web(%d,%d) ' % (self._get_offset(page), self.result_limit) query += "WHERE query = '%s'" % yterm yql_api = YQLApi() response = yql_api.request(query=query) hits = self._extract_hits(response) return self.render(data=hits, title='Blips for %s' % term, extra_format='blip')
def bookmarks(self, term): term = term.strip() order = None if term and term.find("#") + 1: term, order = term.split("#", 1) term = term.strip() order = order.strip() if term == "": return "Please specify your url to lookup" table = "delicious.feeds" if order == "pop": table += ".popular" query = 'select * from %s (15) where tag="%s"' % (table, term) yql_api = YQLApi(community=True) response = yql_api.request(query) hits = response.get("item") if response else None return self.render(data=hits, title="Bookmarks for %s:" % term)