zoomeye的接口网上不少人做过实现,之前在学python的json信息处理,便写了这个一个利用脚本,唯一的坑就是wiki和返回信息不一样,浪费了点时间。
没有多少难度,就是写了不少提示符,用来多次和提示输入。
#coding:utf-8
#author:misaki
import requests
import json
import re
def geturl():
app = raw_input('app:')
app2 = input('page:')
app3 = raw_input('country:')
for i in xrange(1,app2+1):
i=str(i)
url='https://api.zoomeye.org/web/search?query=app:'+app+'&page='+i+'&country='+app3
r2=requests.get(url,headers=headers)
soup = r2.text
a=json.loads(soup) #获取site
for i in a['matches']:
f=open(app+'.txt','a')
f.write(str(i['site'])+'\n')
f.close
print 'All url number: %s' % len(open(r"web.txt", 'rU').readlines())
print '\r'
zoom = raw_input('Are you continue?[y/n]:')
print '\r'
while zoom not in ['y','n','Y','N']:
print "Please enter the specified letter!"
zoom = raw_input('Are you continue?[y/n]:')
print '\r'
if zoom in ['y','Y']:
main()
def getip():
app4 = raw_input('app:')
app5 = input('page:')
app6 = raw_input('country:')
for i in xrange(1, app5 + 1):
i = str(i)
url = 'https://api.zoomeye.org/host/search?query=' + app4 + '&page=' + i +'&country=' + app6
r2 = requests.get(url, headers=headers)
parrten = re.compile(r'(?<![\.\d])(?:\d{1,3}\.){3}\d{1,3}(?![\.\d])') #获取ip
ip = parrten.findall(str(r2.text))
for i in ip:
f = open(app4+'.txt', 'a')
f.write(str(i) + '\n')
f.close
print 'All url number: %s' % len(open(r"host.txt", 'rU').readlines())
print '\r'
zoom = raw_input('Are you continue?[y/n]:')
while zoom not in ['y','n','Y','N']:
print "Please enter the specified letter!"
zoom = raw_input('Are you continue?[y/n]:')
print '\r'
if zoom in ['y','Y']:
main()
def getuser():
url = 'https://api.zoomeye.org/resources-info'
r2 = requests.get(url, headers=headers)
soup = json.loads(r2.text)
print '\r'
print 'plan: %s' %soup['plan']
print 'search_num: %s' %soup['resources']['search']
print 'stats: %s' %soup['resources']['stats']
def main():
print 'Input service number'
print '1 - web_search'
print '2 - host_search'
print '3 - resources_info'
name = raw_input('input num:')
print '\r'
while name not in ['1','2','3']:
name = raw_input('input num:')
if name != '':
try:
if name == '1':
geturl()
elif name == '2':
getip()
elif name == '3':
getuser()
except:
pass
if __name__=='__main__':
print '#######'
print ' # #### #### # # ###### # # ######'
print ' # # # # # ## ## # # # # '
print ' # # # # # # ## # ##### # ##### '
print ' # # # # # # # # # # '
print ' # # # # # # # # # # '
print '####### #### #### # # ###### # ######'
print 'auther:misaki'
print '\r'
print 'Input your username and password'
username = raw_input('username:')
password = raw_input('password:')
print '\r'
if username and password != -1:
data = {"username": username, "password": password}
s = json.dumps(data, indent=4)
r = requests.post('https://api.zoomeye.org/user/login', data=s)
if r.status_code == 200:
token = r.text
headers = {'Authorization': 'JWT' + ' ' + token[18:-2]}
main()
else:
print 'Incorrect username or password'