Python scripts based on the Zoomeye Zhong eye API

Source: Internet
Author: User

The use effect is as follows:

The code is as follows:

#-*-coding:cp936-*-import OS import Requests page = 1 #输入个人账号密码 user = ' passwd = ' #验证用户名 Password, return Access_token def Check (): Data_info = {' username ': User, ' Password ': passwd} try:respond = re Quests.post (url = ' Https://api.zoomeye.org/user/login ', JSON = data_info) except requests.
    Requestexception as E:print ("[-]%s"% e) print ([-] connection failed! ")
        Else:if Respond.status_code==200:access_token=respond.json () return Access_token 
            Else:print ("[-]%s%s \n[-]%s"% (Respond.status_code, Respond.json () ["Error"], Respond.json () ["Message"])
      
          
Print ("[-] Connection failed!") 
 
Def search (): Global mode,query mode=raw_input (' Please select the type to search: Host | web\n ') query=raw_input (' Enter the keyword to query: \ n ') 
        def getrespose (access_token): authorization = {' authorization ': ' JWT ' + access_token[' Access_token ']} try: respond = requests.get (url = ' https://api.zoomeye.org/' +mode+ '/search?query= ' + query+ ' &page= ' + str (page), headers = authorization) except requests. Requestexception as E:print ("[-]%s"% e) print ("[-]%s retrieval failed!"% mode.capitalize ()) else:if Respond.status_code = = 200:return Respond.json () else:print ("[-]%s%s \n[-]%s"% (re Spond.status_code, Respond.json () ["Error"], Respond.json () ["message"]) print ("[-]%s retrieval failed!"% mode.capitalize
            () def output_data (temp): result = List () if mode = = ' host ': For line in temp[' matches ': Result.append (line["IP" + ":" + str (line["Portinfo"] ["port"]) + "\ n") Else:for line in temp["Mat" Ches "]: Result.append (line[" site "+" \ n ") Return to result def Mian ():     Global 
Page     Access_token = Check ()     search ()     if not access_token:           Sys.exit ()     else:         Pass      result = List ()     if search:         max_page = int (input (' Please enter the maximum number of pages (10 per page): \ n '))           while Page<=max_page:              temp=getrespose (Access_token)              If not temp:                  print (' [-] retrieve complete! ')           
      Break             Else:                 if not temp["matches"] :                     print (' [-] no data! ')                      Break                  Else:                      result.extend (Output_data (temp))                      print (' [-] Start download page%s '% page]              page +=1     result = Set (Result)   & nbsp With open (' ZoomEyes.txt ', "w") as F:         f.writelines (Result)      F.close ()                          If __name__ = ' __main__ ':       Mian() 

 


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.