<commit_before># rb_zoomeye

zoomeye api for ruby.

## Install
``` bash
gem install zoomeye
```

## Reference

As the official website, the interfaces provided encapsulation are below:

+ login

login with username and password, get an access token. for the details, please read the official api doc:
[https://www.zoomeye.org/api/doc#user](https://www.zoomeye.org/api/doc#user)

+ resouces_info

get resources info for account. for the details, please read the official api doc:

[https://www.zoomeye.org/api/doc#resources-info](https://www.zoomeye.org/api/doc#resources-info)

+ host_search

search the host devices. for the details, please read the official api doc:

[https://www.zoomeye.org/api/doc#host-search](https://www.zoomeye.org/api/doc#host-search)


+ web_search

search the web technologies. for the details, please read the official api doc:

[https://www.zoomeye.org/api/doc#web-search] (https://www.zoomeye.org/api/doc#web-search)

**normally, a dict type is returned when call all above apis, except the 'login' api.**


## 异常捕获

``` ruby
class ZoomEyeError < StandardError
  attr_reader :code, :desc
  def initialize(code, desc)
    @code = code      # string: http status code
    @desc = desc      # string: http message
  end

  # return exceptial mesesage.
  def message
    "[#{@code}]#{@desc}"
  end
end

```

## Example

``` ruby
#!/usr/bin/ruby -w
# -*- coding: utf-8 -*-
require File.dirname(__FILE__) + '/../zoom_eye.rb'

if __FILE__ == $0
  begin
    ze = ZoomEye.new(("<EMAIL>", "foopass")
    ze.login
    puts ze.resources
    puts ze.host_search("port:80", 7, "app,device")
    puts ze.web_search("port:21", 1, "webapp,os")
  rescue => e
    puts e.message
  end
end
```
<commit_msg>require 'zoomeye'<commit_after># rb_zoomeye

zoomeye api for ruby.

## Install
``` bash
gem install zoomeye
```

## Reference

As the official website, the interfaces provided encapsulation are below:

+ login

login with username and password, get an access token. for the details, please read the official api doc:
[https://www.zoomeye.org/api/doc#user](https://www.zoomeye.org/api/doc#user)

+ resouces_info

get resources info for account. for the details, please read the official api doc:

[https://www.zoomeye.org/api/doc#resources-info](https://www.zoomeye.org/api/doc#resources-info)

+ host_search

search the host devices. for the details, please read the official api doc:

[https://www.zoomeye.org/api/doc#host-search](https://www.zoomeye.org/api/doc#host-search)


+ web_search

search the web technologies. for the details, please read the official api doc:

[https://www.zoomeye.org/api/doc#web-search] (https://www.zoomeye.org/api/doc#web-search)

**normally, a dict type is returned when call all above apis, except the 'login' api.**


## 异常捕获

``` ruby
class ZoomEyeError < StandardError
  attr_reader :code, :desc
  def initialize(code, desc)
    @code = code      # string: http status code
    @desc = desc      # string: http message
  end

  # return exceptial mesesage.
  def message
    "[#{@code}]#{@desc}"
  end
end

```

## Example

``` ruby
#!/usr/bin/ruby -w
# -*- coding: utf-8 -*-
require 'zoomeye'

if __FILE__ == $0
  begin
    ze = ZoomEye.new(("<EMAIL>", "foopass")
    ze.login
    puts ze.resources
    puts ze.host_search("port:80", 7, "app,device")
    puts ze.web_search("port:21", 1, "webapp,os")
  rescue => e
    puts e.message
  end
end
```

{'fraction_non_alphanumeric': 0.14008810572687225, 'fraction_numerical': 0.004698972099853157, 'mean_word_length': 3.6914600550964187, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 16, 'lorem ipsum': 0, 'www.': 16, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7402250', 'n_tokens_mistral': 1215, 'n_tokens_neox': 1183, 'n_words': 336}