fofa 0.3.5 → 0.3.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b606d3c74e7a72421fbed9e71bbfca25c6d6d04f
4
- data.tar.gz: 43e5737e0f67c22e92521e7fd33f73b9d46328a0
3
+ metadata.gz: 3ce6f70d71b8ce5f95639e85ec14c4be632d37fa
4
+ data.tar.gz: 5aa510e4d45309d56ac7e1b3e53c604000c602b7
5
5
  SHA512:
6
- metadata.gz: 2760f21dd6300a39d30e58688c08651390542ceac468fff5b0cebf500f316c761880fc944f143229ad6b8843067c6123afb3444f7d7cf3491505d7aefb17ab85
7
- data.tar.gz: 0b8fccd0f3fdd6a47c67714cc366489cfd1330c04c5112021f25deb2b3f32f337192339e39da75a5d1ffab76775b87c9f2146b45a23480eee83ecd4f090325e0
6
+ metadata.gz: 7a4ed37b9e7182f1d4efa45910174f53512c02b8166c02fef7d67830597428fbf357f3e29b74e6787378c99220130edbaea3221c2e5848343b4f30adc76f08b7
7
+ data.tar.gz: c1210f6b9c8a85e554caeeb6db49941a5c2a8995ef10d601574e1e883c9058d099ac87935ac7c193db17e0a539180f359876fa8dc59e5a921ea79af46639de5d
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- fofa (0.3.4)
4
+ fofa (0.3.6)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -34,4 +34,4 @@ DEPENDENCIES
34
34
  rspec (~> 3.0)
35
35
 
36
36
  BUNDLED WITH
37
- 1.13.7
37
+ 1.14.6
@@ -15,11 +15,11 @@ module Fofa
15
15
  # Search page results from fofa
16
16
  #
17
17
  # Example 1:
18
- # >> Fofa::API.new(email,apikey).search("host==baidu.com")
18
+ # >> Fofa::API.new(email,apikey).search("host=baidu.com")
19
19
  # => {size:1, results:['1.1.1.1']}
20
20
  #
21
21
  # Example 2:
22
- # >> Fofa::API.new(email,apikey).search("host==baidu.com", fields:'host,title,ip')
22
+ # >> Fofa::API.new(email,apikey).search("host=baidu.com", fields:'host,title,ip')
23
23
  # => {size:1, results:[['1.1.1.1:81', 'title', '1.1.1.1']]}
24
24
  #
25
25
  # Arguments:
@@ -47,17 +47,27 @@ module Fofa
47
47
  # >> Fofa::API.new(email,apikey).search_all("domain==baidu.com") {|results, page| ... }
48
48
  # => {size:1, results:['1.1.1.1:80']}
49
49
  #
50
+ # Example:
51
+ # >> Fofa::API.new(email,apikey).search_all("domain==baidu.com", fields:'host,title,ip') {|results, page| ... }
52
+ # => {size:1, results:[['1.1.1.1:81', 'title', '1.1.1.1']]}
53
+ #
50
54
  # Arguments:
51
55
  # query: (String) fofa query string
52
- def search_all(query)
56
+ def search_all(query, options={})
57
+ all_size = options.delete :size # do not pass to search
53
58
  all_res = []
54
59
  page = 0
55
60
  loop do
56
61
  page += 1
57
- res = search(query, {page:page})
62
+ res = search(query, {page:page}.merge(options))
58
63
  if !res['error'] && res['results'].size > 0
59
64
  all_res += res['results']
60
65
  yield(res['results'], page) if block_given?
66
+
67
+ if all_size && all_res.size > all_size.to_i
68
+ all_res = all_res[0..all_size-1]
69
+ break
70
+ end
61
71
  else
62
72
  break
63
73
  end
@@ -1,5 +1,5 @@
1
- # 0.3.5
1
+ # 0.3.6
2
2
  # add fields
3
3
  module Fofa
4
- VERSION = "0.3.5"
4
+ VERSION = "0.3.6"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fofa
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.5
4
+ version: 0.3.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - fofa