def do_query(word, key): ''' try: for r in query.execute(): try: yield r.url.decode('utf-8').encode('utf-8') except: pass except: pass ''' #query = WebQuery(key, word, filetype.upper()) query = WebQuery(key, word) for r in query.execute(): yield parse_qs(urlparse(r.url.decode('utf-8').encode('utf-8')).query)["r"][0]
def startBingScan(self): print "Querying Bing Search: '%s' with max Bing results %d..."%(self.config["p_query"], self.config["p_bingresults"]) self.config["p_logger"].info("Querying Bing Search: '%s' with max Bing results %d..."%(self.config["p_query"], self.config["p_bingresults"])) query = WebQuery(self.config["p_bingkey"], query=self.config["p_query"]) results = query.execute() enlaces = [] resultsbing = self.config["p_bingresults"] for result in results[:resultsbing]: enlaces.append(result.url) enlaces_uniq = list(set(enlaces)) self.config["p_enlaces"] = enlaces_uniq if (len(enlaces) == 0): sys.stderr.write("Not results by bing search\n") self.config["p_logger"].warning('Not results by bing search\n') sys.exit(0) try: return self.config except KeyboardInterrupt,err: raise self.config["p_logger"].error(err)
## from pybing import Bing ## import urllib ## bing=Bing('<E6C1E113773ED242B82E03F49740BACD17FDAA36>') ## response=bing.search_web('global street fashion') ## print response['SearchResponse']['Web']['Total'] from pybing.query import WebQuery query=WebQuery('E6C1E113773ED242B82E03F49740BACD17FDAA36',query='global street fashion') results=query.execute() for result in results[:3]: print repr(result.title)