def __init__(self, config): self.config = config self.bs = Bing("YOUR ID") self.cooldown = self.config["p_googlesleep"] self.results_per_page = int(self.config["p_results_per_query"]) if (self.config["p_skippages"] > 0): print "Bing Scanner will skip the first %d pages..." % ( self.config["p_skippages"])
class BingSearcher(Searcher): def __init__(self, app_id): self.bing = Bing(app_id) def _num_results_for(self, term): response = self.bing.search_web(term) return response['SearchResponse']['Web']['Total']
def __init__(self, config): self.config = config self.bs = Bing("YOUR ID") self.cooldown = self.config["p_googlesleep"]; self.results_per_page = int(self.config["p_results_per_query"]); if (self.config["p_skippages"] > 0): print "Bing Scanner will skip the first %d pages..."%(self.config["p_skippages"])
class Image(): def __init__(self): self.bing = Bing(BING_ID) def _download(self, url, filename, content_type): try: req = urllib2.Request(url.encode('utf-8'), None, \ {'Content-Type':content_type}) response = urllib2.urlopen(req) fp = open(filename, 'w') fp.write(response.read()) response.close() fp.close() return True except: return False def get_image(self, concept, filename, dirname): response = self.bing.search_image(concept.encode('utf-8')) if 'Image' not in response['SearchResponse'].keys(): return None if 'Results' not in response['SearchResponse']['Image'].keys(): return None for result in response['SearchResponse']['Image']['Results']: image_url = result['MediaUrl'] thumbnail_url = result['Thumbnail']['Url'] extension = image_url.split('.')[-1].split('&')[0].split('?')[0] content_type = result['Thumbnail']['ContentType'] new_filename = filename+'.'+extension print new_filename.encode('utf-8') if self._download(thumbnail_url, dirname+new_filename, content_type) is True: return new_filename else: continue
def do_test(self,asgbtrh): str= "\"ash is a ash is \" a ash" bing = Bing('tDPxzhwtkNX2hYu72irEhlPpFzg36bAcsX3fqbRiGS4='); response = bing.search_web('python bing') print response results = response['SearchResponse']['Web']['Results'] print len(results) for result in results: print repr(result['Title']) splittd= str.split("\"") print splittd for word in splittd: print "splitting.. ",word.split("\""),"\n" p={} o="" if len(list(p))==0: print "!p"
""" Created on Tue Sep 10 11:34:59 2013 @author: ozdemircili """ """ Do not forget to install the API by: pip install pybing """ from pybing import Bing bing = Bing('<addyourappidhere') response = bing.search.web('pycheat github') print response['SearchResponse']['Web']['Total'] results = response['SearchResponse']['Web']['Results'] print len(results)
def __init__(self, app_id): self.bing = Bing(app_id)
class bingScan: def __init__(self, config): self.config = config self.bs = Bing("YOUR ID") self.cooldown = self.config["p_googlesleep"]; self.results_per_page = int(self.config["p_results_per_query"]); if (self.config["p_skippages"] > 0): print "Bing Scanner will skip the first %d pages..."%(self.config["p_skippages"]) def startGoogleScan(self): print "Querying Bing Search: '%s' with max pages %d..."%(self.config["p_query"], self.config["p_pages"]) pagecnt = 0 curtry = 0 last_request_time = datetime.datetime.now() while(pagecnt < self.config["p_pages"]): pagecnt = pagecnt +1 redo = True while (redo): try: current_time = datetime.datetime.now() diff = current_time - last_request_time diff = int(diff.seconds) if (diff <= self.cooldown): if (diff > 0): print "Commencing %ds bing cooldown..." %(self.cooldown - diff) time.sleep(self.cooldown - diff) last_request_time = datetime.datetime.now() resp = self.bs.search_web(self.config["p_query"], {'Web.Count':50,'Web.Offset':(pagecnt-1)*self.results_per_page}) results = resp['SearchResponse']['Web']['Results'] redo = False except KeyboardInterrupt: raise except Exception, err: raise redo = True sys.stderr.write("[RETRYING PAGE %d]\n" %(pagecnt)) curtry = curtry +1 if (curtry > self.config["p_maxtries"]): print "MAXIMUM COUNT OF (RE)TRIES REACHED!" sys.exit(1) curtry = 0 if (len(results) == 0): break sys.stderr.write("[PAGE %d]\n" %(pagecnt)) try: for r in results: single = singleScan(self.config) single.setURL(r["Url"]) single.setQuite(True) single.scan() except KeyboardInterrupt: raise time.sleep(1) print "Bing Scan completed."
def __init__(self): self.bing = Bing(BING_ID)
class bingScan: def __init__(self, config): self.config = config self.bs = Bing("YOUR ID") self.cooldown = self.config["p_googlesleep"] self.results_per_page = int(self.config["p_results_per_query"]) if (self.config["p_skippages"] > 0): print "Bing Scanner will skip the first %d pages..." % ( self.config["p_skippages"]) def startGoogleScan(self): print "Querying Bing Search: '%s' with max pages %d..." % ( self.config["p_query"], self.config["p_pages"]) pagecnt = 0 curtry = 0 last_request_time = datetime.datetime.now() while (pagecnt < self.config["p_pages"]): pagecnt = pagecnt + 1 redo = True while (redo): try: current_time = datetime.datetime.now() diff = current_time - last_request_time diff = int(diff.seconds) if (diff <= self.cooldown): if (diff > 0): print "Commencing %ds bing cooldown..." % ( self.cooldown - diff) time.sleep(self.cooldown - diff) last_request_time = datetime.datetime.now() resp = self.bs.search_web( self.config["p_query"], { 'Web.Count': 50, 'Web.Offset': (pagecnt - 1) * self.results_per_page }) results = resp['SearchResponse']['Web']['Results'] redo = False except KeyboardInterrupt: raise except Exception, err: raise redo = True sys.stderr.write("[RETRYING PAGE %d]\n" % (pagecnt)) curtry = curtry + 1 if (curtry > self.config["p_maxtries"]): print "MAXIMUM COUNT OF (RE)TRIES REACHED!" sys.exit(1) curtry = 0 if (len(results) == 0): break sys.stderr.write("[PAGE %d]\n" % (pagecnt)) try: for r in results: single = singleScan(self.config) single.setURL(r["Url"]) single.setQuite(True) single.scan() except KeyboardInterrupt: raise time.sleep(1) print "Bing Scan completed."