调用ZoomEye API获取信息
最近在提高自己编程能力,拿一些实用的小工具练下。该脚本为python语言,主要涉及模块urllib,json,os模块。
功能:调用ZoomEye API获取信息
import urllib.request
import json
import os def login():
username = input("username:")
password = input("password:")
url = "https://api.zoomeye.org/user/login"
data = json.dumps({'username':username,'password':password})
data_bytes = bytes(data,'utf8')
try:
req = urllib.request.Request(url,data_bytes)
response = urllib.request.urlopen(req)
html = response.read().decode('utf-8')
target = json.loads(html) access_token = target['access_token']
with open('access_token.txt','w') as f:
f.write(access_token)
f.close
print('login seccess !!!')
#print('your access_token is:%s'%(access_token))
except Exception as err:
print('[info]:username or password is wrong !') def apiget():
while True:
host_or_web = input("search for host or web:(‘q!’Sign out):")
if host_or_web == 'q!':
break
query = input("input your keyword(-r for your resources-info):") #查看自己的套餐剩余量
if query == '-r':
req = urllib.request.Request('https://api.zoomeye.org/resources-info')
ida = open('access_token.txt').read() req.add_header('Authorization','JWT %s'%(ida))
re = urllib.request.urlopen(req)
ae = (re.read().decode('utf-8'))
ae = target = json.loads(ae)
dict_web = ae['resources']['web-search']
dict_host = ae['resources']['host-search']
print('your web search:%s'%(dict_web))
print('your host search:%s'%(dict_host))
else:
try:
req = urllib.request.Request('https://api.zoomeye.org/%s/search?query=%s'%(host_or_web,query))
idb = open('access_token.txt').read()
req.add_header('Authorization','JWT %s'%(idb))
r = urllib.request.urlopen(req)
a = (r.read().decode('utf-8'))
a = target = json.loads(a)
print('tatal:%s'%(a['total']))
for i in range(len(a['matches'])):
print (a['matches'][i]['ip']) except Exception as err:
print('[erro]:Please enter the correct syntax !') def start():
if not os.path.isfile('access_token.txt'): #首次使用会检查脚本目录下access_token.txt文件,没有的话登录会创建
print('[info]:you need login')
login() apiget() if __name__ == '__main__':
start()


调用ZoomEye API获取信息的更多相关文章
- 『Python』Python 调用 ZoomEye API 批量获取目标网站IP
#### 20160712 更新 原API的访问方式是以 HTTP 的方式访问的,根据官网最新文档,现在已经修改成 HTTPS 方式,测试可以正常使用API了. 0x 00 前言 ZoomEye 的 ...
- 记-beego项目调用Jenkins API获取job信息
type JenkinsController struct { beego.Controller } type Job struct { Name string `json:"name&qu ...
- js调用高德API获取所在当前城市
可以在js代码中直接调用API接口,获取所处当前城市信息,代码如下: <script type="text/javascript"> function getCurre ...
- Vue 通过调用百度API获取地理位置-经度纬度省份城市
一.首先在百度api注册获得ak密钥 二.新建js文件,我命名为loadBMap.js,里面创建script,代码如下: /** * 加载地图 * @param {Function} callback ...
- 调用windows api 获取系统分辨率
c++中: int cxScreen,cyScreen; cxScreen=GetSystemMetrics(SM_CXSCREEN); cyScreen=GetSystemMetrics(SM_CY ...
- C# 调用win api获取chrome浏览器中地址
//FindWindow 查找窗口 //FindWindowEx查找子窗口 //EnumWindows列举屏幕上的所有顶层窗口,如果回调函数成功则返回非零,失败则返回零 //GetWindowText ...
- android调用webservice接口获取信息
我的有一篇博客上讲了如何基于CXF搭建webservice,service层的接口会被部署到tomcat上,这一篇我就讲一下如何在安卓中调用这些接口传递参数. 1.在lib中放入ksoap2的jar包 ...
- Java调用yahoo!API获取天气数据
先把代码复制上来,以后再做补充 package com.weather.test; import java.io.InputStream; import java.net.URL; import ja ...
- C# 通过豆瓣网络编程API获取图书信息
这篇文章主要是关于如何通过豆瓣API获取信息的书籍,起初,我看到了原来的想法的内容是"C# 网络编程之网页简单下载实现"中通过HttpWebResponse类下载源代码,再通过正則 ...
随机推荐
- [转]Inside Swift
原文地址:http://www.eswick.com/2014/06/inside-swift/ Inside Swift Swift is Apple's new programming lan ...
- Nvelocity模板引擎开发网页
在ASP.NET网站开发中,我们要做许多的网页,如果多个网页的内容框架有些重复使用,我们用NVelocity模板引擎,就可以把相同的部分html代码单独放在一个文件中就行了,当要使用的时候,只需使用# ...
- EventBus实现 - 发布订阅 - XML加载
EventBus实现 - 发布订阅 - XML加载 受到CQRS的影响,写了个EventBus,能实现发布订阅模式执行event,在DDD模型中,可以使用如下代码触发事件: EventBus bus ...
- TOGAF架构内容框架之内容元模型(上)
TOGAF架构内容框架之内容元模型(上) 2. 内容元模型(Content Metamodel) 在TOGAF的眼中,企业架构是以一系列架构构建块为基础的,并将目录.矩阵和图形作为其具体展现方式.如果 ...
- Quagga添加自己的命令
参考了王斌的文档:http://down.51cto.com/data/621454 TIP:笔者使用的版本是0.99.20 需求:在接口模式下添加一条"ip ospf enable&quo ...
- [置顶] IT老男人读《因为痛,所以叫青春》
最近偶然,从别人的书桌上看到这本书,其中有个关于时间的解释,很是让为成功焦虑的老男人受用. 因此,我喜欢将人生的80年跟一天中的24小时进行对照. 人生时钟的计算方法十分简单.24小时相当于144 ...
- hdu 1217
判断通过货币的兑换能否获利,,最短路,这里是乘法,, #include<stdio.h> #include<string.h> double map[31][31],ans[3 ...
- java.util.List 的大小
今天在看API的时候,忽然看见List对象的size()方法返回的是int类型,于是就想知道是不是只能存放int的最大数值2147483647个. 但是,用自己电脑跑了一下,代码如下: public ...
- Js-Html 前端系列--Ajax
最近在做Web项目,用到很多Ajax,也遇到很多问题.下面与大家分享. Ajax传参 Ajax同步与异步 Ajax与谷歌浏览器 Ajax传参 我们一般传参有两种形式: $.ajax({ ... dat ...
- Thymeleaf 笔记
th:each=”aname : ${namelist}” th:if=”${name} == ‘SERVICED’” 页面使用Map集合 <div th:each="osl : ${ ...