用Bing API接口实现同IP域名查询(Python版)


1、在https://datamarket.azure.com/account/datasets这里注册帐号后申请一个免费的KEY,一个月可以查询5000次,其申请方法网上有很多教程了。

2、此脚本使用Sqlite作数据库,申请的KEY可以在使用前保存在数据库中。使用方法看使用提示。



3、使用示例:

       bing.py -add P1f3+ZAPBRv/wy7i3bxxxxxm2MXq3aA+iuu1UT6ypkY             //保存一个key到数据库中

       bing.py -set 1                                                     //把ID为1的Key设为默认使用的KEY.

       bing.py -url www.google.com                         //查询google.com同IP的其他域名

       bing.py -url 192.168.1.1-192.168.1.254 -save       //查询指定IP段的域名,并保存到数据库中以便查询

       bing.py -url -view                                               //浏览数据库中保存的数据

 

以下是Python代码:

# -*- coding: utf-8 -*-
#https://datamarket.azure.com/account/datasets
#Code by Anle
import sys
import urllib  
import urllib2  
import base64
import sqlite3
import socket
import struct
import time
from datetime import datetime,timedelta
try:  
    import json  
except ImportError:  
    import simplejson as json
   
AccountKey=''  
top=100  
skip=0
formats='json'
useCounts = 0
useID = 0
ConfigFile='%s\\bing.db' % (sys.path[0])

def _usage():
    print 'Bing Domain dig Usage:'
    print '\t%s <options> [Host]' % sys.argv[0]
    print 'Options:\t'
    print '-url\t\tOnly view url.\t'
    print '-uri\t\tView url of full path.\t'
    print '-desc\t\tView description info.\t'
    print '-key\t\tView all account key.\t'
    print '-add <key>\tAdd a key to database.\t'
    print '-set <id> [num]\tSet a key to current use.\t'
    print '-del <id>\tDelete a key from database.\t'
    print '-view\t\tView the last saved record.\t'
    print '-save\t\tSave to databse.\t'
    print '-export <path>\tExport data to file.\n'

def CheckDatabaseExist():
    szSQL="SELECT name FROM sqlite_master WHERE type='table' order by name;"
    try:
        conn=sqlite3.con
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值