ZoomQuiet avatar ZoomQuiet committed 9b1540f

collection v1 zip codes

Comments (0)

Files changed (2)

+# -*- coding: utf-8 -*-
+VERSION = "urisaok v11.12.28"
+import sae
+import urllib2 as urilib
+from bottle import Bottle, request
+app = Bottle()
+
+@app.route('/')
+def hello():
+    return '''%s powerded by Bottle + SAE !
+    usage:
+    $ curl -d 'uri=http://sina.com' 1.urisaok.sinaapp.com/chk/
+        '''% VERSION
+
+@app.route('/chk/', method="POST")
+def chk():
+    uri = request.forms.get('uri')
+    print uri
+    result = _askCloud(APITYPE, uri)
+    return "/chk %s"% result
+
+import base64
+import time
+from hashlib import md5
+APPKEY = "k-60666"
+SECRET = "99fc9fdbc6761f7d898ad25762407373"
+OPEN_HOST = "open.pc120.com"
+APITYPE = "/phish/"
+PHISHTYPE = {'-1':'未知'
+    ,'0':'非钓鱼'
+    ,'1':'钓鱼'
+    ,'2':'网站高风险,有钓鱼嫌疑'
+    }
+
+def _askCloud(api_path, url):
+    args = __genQueryArgs(api_path, url)
+    api_url = "http://%s%s?%s"% (OPEN_HOST, APITYPE ,args)
+    print api_url
+    result = eval(urilib.urlopen(api_url).read())
+    print result
+    if result['success'] == 1:
+        doc = result['phish']
+        return "%s:: %s"% (doc, PHISHTYPE[str(doc)])
+    else:
+        return result
+
+def __genQueryArgs(api_path, url):
+    args = "appkey=" + APPKEY
+    args += "&q=" + base64.urlsafe_b64encode(url)
+    args += "&timestamp=" + "%.3f" % (time.time())
+    sign_base_string = api_path + "?" + args
+    args += "&sign=" + md5(sign_base_string + SECRET).hexdigest()
+    return args
+
+application = sae.create_wsgi_app(app)
 # -*- coding: utf-8 -*-
 VERSION = "urisaok v11.12.28"
-'''网址云RESTful API 包装服务:
-    - 111226 clone into SAE
-    - 110324 clone into GAE
-    - 110323 init.
-依赖:
-    + bottle
-'''
-
+import sae
+import urllib2 as urilib
 from bottle import Bottle, request
 
-import sae
-import urllib2 as urilib
+app = Bottle()
+
+@app.route('/')
+def hello():
+    return '''%s powerded by Bottle + SAE !
+    usage:
+    $ curl -d 'uri=http://sina.com' 1.urisaok.sinaapp.com/chk/
+        '''% VERSION
+
+@app.route('/chk/', method="POST")
+def chk():
+    uri = request.forms.get('uri')
+    print uri
+    result = _askCloud(cfg.APITYPE, uri)
+    return "/chk %s"% result
 
 import base64
 import time
 from hashlib import md5
-
 class Borg():
     '''base http://blog.youxu.info/2010/04/29/borg
         - 单例式配置收集类
         ,'1':'钓鱼'
         ,'2':'网站高风险,有钓鱼嫌疑'
         }
-
 # init all var
 cfg = Borg()
 
-app = Bottle()
-
-@app.route('/')
-def hello():
-    return "Hello, world! - Bottle @ SAE 4 urisaok!{v12.01.12} from YY talking.."
-
-@app.route('/chk/', method="POST")
-def chk():
-    uri = request.forms.get('uri')
-    print uri
-    #result = "try chk"
-    result = _askCloud(cfg.APITYPE, uri)
-    return "/chk %s"% result
-
-@app.route('/ask/:uri')
-def ask(uri):
-    print uri
-    result = _askCloud(cfg.APITYPE, uri)
-    return "/ask %s"% result
-
 def _askCloud(api_path, url):
     args = __genQueryArgs(api_path, url)
-    key_values = [("%s=%s" % (k, v)) for k, v in args.iteritems()]
-    api_url = "http://%s/%s/"% (cfg.OPEN_HOST, api_path) + "?" + "&".join(key_values)
+    api_url = "http://%s%s?%s"% (cfg.OPEN_HOST, cfg.APITYPE ,args)
     print api_url
     result = eval(urilib.urlopen(api_url).read())
-    #print type(result)
     print result
     if result['success'] == 1:
         doc = result['phish']
         return result
 
 def __genQueryArgs(api_path, url):
-    args = {}
-    args["appkey"] = cfg.APPKEY
-    args["q"] = base64.urlsafe_b64encode(url)
-    args["timestamp"] = "%.3f" % (time.time())
-    sign_base_string = __genSignString(api_path, args)
-    args["sign"] = md5(sign_base_string + cfg.SECRET).hexdigest()
-    #print args, sign_base_string
+    args = "appkey=" + cfg.APPKEY
+    args += "&q=" + base64.urlsafe_b64encode(url)
+    args += "&timestamp=" + "%.3f" % (time.time())
+    sign_base_string = api_path + "?" + args
+    args += "&sign=" + md5(sign_base_string + cfg.SECRET).hexdigest()
     return args
-    
-def __genSignString(api_path, args):
-    keys = args.keys()
-    keys.sort()
-    key_values = []
-    for k in keys:
-        v = args[k]
-        key_values.append("%s=%s" % (k, v))
-    base_string = api_path + "?" + "&".join(key_values)
-    return base_string
-
 
 application = sae.create_wsgi_app(app)
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.