示例#1
0
 def post(self):  # should run at most 1/s
     url = self.request.get("url")
     b64 = base64.b64encode(url)
     h = make_scraper(url)
     img = h.largest_image_url()
     logging.info("Image for %s found: %s", url, img)
     if img is None:
         # We want to set a value anyway... to avoid people asking for that url again over and over.
         memcache.set(b64, "", 86400)
     else:
         memcache.set(b64, img, 86400)
示例#2
0
 def post(self): # should run at most 1/s
     url = urllib.unquote(self.request.get("url", ''))
     hsh = hashlib.sha1(url).hexdigest()
     h = make_scraper(url)
     img = h.largest_image_url()
     logging.info('Image for %s found: %s', url, img)
     if img is None:
         # We want to set a value anyway... to avoid people asking for that url again over and over.
         memcache.set(hsh, "", 86400)        
     else:
         memcache.set(hsh, img, 86400)