|
|
|
|
@ -4,22 +4,23 @@ from importlib.machinery import SourceFileLoader |
|
|
|
|
import json |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def spider(cache, key, api): |
|
|
|
|
def spider(cache, api): |
|
|
|
|
name = os.path.basename(api) |
|
|
|
|
path = cache + '/' + name |
|
|
|
|
downloadFile(path, api) |
|
|
|
|
name = name.split('.')[0] |
|
|
|
|
return SourceFileLoader(name, path).load_module().Spider() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def downloadFile(name, api): |
|
|
|
|
def downloadFile(path, api): |
|
|
|
|
if api.startswith('http'): |
|
|
|
|
writeFile(name, redirect(api).content) |
|
|
|
|
writeFile(path, redirect(api).content) |
|
|
|
|
else: |
|
|
|
|
writeFile(name, str.encode(api)) |
|
|
|
|
writeFile(path, str.encode(api)) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def writeFile(name, content): |
|
|
|
|
with open(name, 'wb') as f: |
|
|
|
|
def writeFile(path, content): |
|
|
|
|
with open(path, 'wb') as f: |
|
|
|
|
f.write(content) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -35,6 +36,16 @@ def str2json(content): |
|
|
|
|
return json.loads(content) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def getDependence(ru): |
|
|
|
|
result = ru.getDependence() |
|
|
|
|
return result |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def getName(ru): |
|
|
|
|
result = ru.getName() |
|
|
|
|
return result |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def init(ru, extend): |
|
|
|
|
ru.init(extend) |
|
|
|
|
|
|
|
|
|
|