esearchy 0.2.0.3 → 0.2.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/bin/esearchy +186 -175
- data/lib/esearchy/esearchy.rb +1 -1
- data/lib/esearchy/genericengine.rb +5 -1
- metadata +2 -2
data/bin/esearchy
CHANGED
@@ -44,6 +44,7 @@ ESearchy::log = true
|
|
44
44
|
@people_engines = [] #[:LinkedIn, :Naymz, :Classmates, :GoogleProfiles]
|
45
45
|
|
46
46
|
opts = GetoptLong.new(
|
47
|
+
[ '--version', '-v', GetoptLong::NO_ARGUMENT ],
|
47
48
|
[ '--help', '-h', GetoptLong::NO_ARGUMENT ],
|
48
49
|
[ '--enable-all', GetoptLong::NO_ARGUMENT ],
|
49
50
|
[ '--enable-people', GetoptLong::NO_ARGUMENT ],
|
@@ -84,11 +85,188 @@ opts = GetoptLong.new(
|
|
84
85
|
[ '--maxhits','-m', GetoptLong::REQUIRED_ARGUMENT ]
|
85
86
|
)
|
86
87
|
|
88
|
+
def logo
|
89
|
+
if RUBY_PLATFORM =~ /mingw|mswin/
|
90
|
+
puts "___________ _________ .__ "
|
91
|
+
puts "\_ _____// _____/ ____ _____ _______ ____ | |__ ___.__."
|
92
|
+
puts " | __)_ \_____ \_/ __ \\__ \\_ __ \_/ ___\| | < | |"
|
93
|
+
puts " | \/ \ ___/ / __ \| | \/\ \___| Y \___ |"
|
94
|
+
puts "/_______ /_______ /\___ >____ /__| \___ >___| / ____|"
|
95
|
+
puts " \/ \/ \/ \/ \/ \/\/ "
|
96
|
+
else
|
97
|
+
puts "\033[31m___________ \033\[0m_________ .__ "
|
98
|
+
puts "\033[31m\\_ _____/\033\[0m/ _____/ ____ _____ _______ ____ | |__ ___.__."
|
99
|
+
puts "\033[31m | __)_ \033\[0m\\_____ \\_/ __ \\\\__ \\\\_ __ \\_/ ___\\| | < | |"
|
100
|
+
puts "\033[31m | \\\033\[0m/ \\ ___/ / __ \\| | \\/\\ \\___| Y \\___ |"
|
101
|
+
puts "\033[31m/_______ /\033\[0m_______ /\\___ >____ /__| \___ >___| / ____|"
|
102
|
+
puts "\033[31m \\/\033\[0m \\/ \\/ \\/ \\/ \\/\\/"
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
def configure(maxhits = nil, yahoo_key = nil, bing_key = nil)
|
107
|
+
File.open(ENV['HOME'] + "/.esearchyrc", "w" ) do |line|
|
108
|
+
line << "MAXHITS=#{maxhits.to_s || "500"}\n"
|
109
|
+
line << "YAHOOKEY=#{yahoo_key.to_s}\n" if yahoo_key
|
110
|
+
line << "BINGKEY=#{bing_key.to_s}\n" if bing_key
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
114
|
+
def read_conf
|
115
|
+
File.open(ENV['HOME'] + "/.esearchyrc").readlines.each do |line|
|
116
|
+
key, value = line.split("=")
|
117
|
+
case key
|
118
|
+
when "MAXHITS" then
|
119
|
+
@params[:maxhits] ||= value.to_i
|
120
|
+
when "YAHOOKEY" then
|
121
|
+
@yahoo_key ||= value
|
122
|
+
when "BINGKEY" then
|
123
|
+
@bing_key ||= value
|
124
|
+
end
|
125
|
+
end
|
126
|
+
end
|
127
|
+
|
128
|
+
def dump(results)
|
129
|
+
# this is for session handling.
|
130
|
+
end
|
131
|
+
|
132
|
+
### PRINTING FINDING METHODS ###
|
133
|
+
def print_(list)
|
134
|
+
unless list.nil?
|
135
|
+
list.each do |item|
|
136
|
+
case item
|
137
|
+
when String
|
138
|
+
case RUBY_PLATFORM
|
139
|
+
when /mingw|mswin/
|
140
|
+
print_windows(item)
|
141
|
+
when /linux|darwin/
|
142
|
+
print_linux(item)
|
143
|
+
end
|
144
|
+
when Array
|
145
|
+
puts item.join " "
|
146
|
+
end
|
147
|
+
end
|
148
|
+
end
|
149
|
+
end
|
150
|
+
|
151
|
+
def print_linux(email)
|
152
|
+
if email.match(/#{ESearchy::Search.query.gsub("@","").split('.')[0]}/i)
|
153
|
+
puts "\033[31m" + email + "\033\[0m"
|
154
|
+
else
|
155
|
+
puts "\033[32m" + email + "\033\[0m"
|
156
|
+
end
|
157
|
+
end
|
158
|
+
|
159
|
+
def print_windows(email)
|
160
|
+
if email.match(/#{ESearchy::Search.query.gsub("@","").split('.')[0]}/i)
|
161
|
+
Wcol.puts(12, email)
|
162
|
+
else
|
163
|
+
Wcol.puts(2, email)
|
164
|
+
end
|
165
|
+
end
|
166
|
+
|
167
|
+
### SAVING TO DISK ###
|
168
|
+
class Output
|
169
|
+
def initialize(name)
|
170
|
+
@output = name
|
171
|
+
end
|
172
|
+
|
173
|
+
def save(data)
|
174
|
+
case @output
|
175
|
+
when /pdf/
|
176
|
+
save_pdf(data)
|
177
|
+
when /csv/
|
178
|
+
save_csv(data)
|
179
|
+
when /sqlite/
|
180
|
+
save_sqlite(data)
|
181
|
+
end
|
182
|
+
end
|
183
|
+
|
184
|
+
private
|
185
|
+
def save_csv(data)
|
186
|
+
out = File.new(@output, "w")
|
187
|
+
out << "EMAILS/PERSON, TYPE, CLASS, MATCH\n"
|
188
|
+
data.each { |r| out << "#{r[0].to_s},#{r[1]},#{r[2]},#{r[3]}\n"}
|
189
|
+
end
|
190
|
+
|
191
|
+
def save_pdf(data)
|
192
|
+
require 'prawn'
|
193
|
+
require 'prawn/layout'
|
194
|
+
|
195
|
+
Prawn::Document.generate(@output) do
|
196
|
+
table data,
|
197
|
+
:position => :center,
|
198
|
+
:headers => ["Email/Person", "Type", "Class", "Match"],
|
199
|
+
:header_color => "0046f9",
|
200
|
+
:row_colors => :pdf_writer, #["ffffff","ffff00"],
|
201
|
+
:font_size => 10,
|
202
|
+
:vertical_padding => 2,
|
203
|
+
:horizontal_padding => 5
|
204
|
+
end
|
205
|
+
end
|
206
|
+
|
207
|
+
def save_sqlite(data)
|
208
|
+
require 'sqlite3'
|
209
|
+
@db = SQLite3::Database.new(@output)
|
210
|
+
@db.execute("CREATE TABLE IF NOT EXISTS results (
|
211
|
+
id integer primary key asc,
|
212
|
+
object text,
|
213
|
+
type char,
|
214
|
+
class text,
|
215
|
+
match char);")
|
216
|
+
|
217
|
+
data.each do |r|
|
218
|
+
@db.execute("INSERT INTO results (object,type,class,match)
|
219
|
+
VALUES (\"#{r[0].to_s}\",\"#{r[1]}\",\"#{r[2]}\",\"#{r[3]}\");")
|
220
|
+
end
|
221
|
+
#@db.commit
|
222
|
+
end
|
223
|
+
end
|
224
|
+
|
225
|
+
def execute(p)
|
226
|
+
if p[:query]
|
227
|
+
search = ESearchy::Search.new(p)
|
228
|
+
|
229
|
+
search.start do |s|
|
230
|
+
unless @email_engines.empty?
|
231
|
+
s.Emails(@email_engines) do |e|
|
232
|
+
e.Yahoo.appid= @yahoo_key if @yahoo_key and @email_engines.include?(:Yahoo)
|
233
|
+
e.Bing.appid= @bing_key if @bing_key and @email_engines.include?(:Bing)
|
234
|
+
e.search do |x|
|
235
|
+
dump(x.results)
|
236
|
+
print_(x.emails.uniq)
|
237
|
+
end
|
238
|
+
if @docs
|
239
|
+
e.docs do |x|
|
240
|
+
dump(x.results)
|
241
|
+
print_(x.emails.uniq)
|
242
|
+
end
|
243
|
+
end
|
244
|
+
end
|
245
|
+
end
|
246
|
+
|
247
|
+
unless @people_engines.empty?
|
248
|
+
s.People(@people_engines) do |p|
|
249
|
+
p.search { |p| dump(p.results) }
|
250
|
+
end
|
251
|
+
end
|
252
|
+
end
|
253
|
+
@output.save(search.results) if @output
|
254
|
+
puts "-------FINAL RESULTS--------"
|
255
|
+
print_ search.emails
|
256
|
+
print_ search.people
|
257
|
+
end
|
258
|
+
end
|
259
|
+
|
87
260
|
opts.each do |opt, arg|
|
88
261
|
case opt
|
262
|
+
when '--version' then
|
263
|
+
logo
|
264
|
+
puts "ESearchy Version #{ESearchy::VERSION}"
|
265
|
+
exit(1)
|
89
266
|
when '--help' then
|
90
267
|
# BEGIN OF HELP
|
91
|
-
|
268
|
+
logo
|
269
|
+
puts "\nHELP for Esearchy\n---------------------\n"
|
92
270
|
puts "--help, -h"
|
93
271
|
puts "\tWell I guess you know what this is for (To obtain this Help).\n"
|
94
272
|
puts "INPUT PARAMS:"
|
@@ -127,14 +305,16 @@ opts.each do |opt, arg|
|
|
127
305
|
puts "\t Enables Google Profiles searches.\n"
|
128
306
|
puts "--enable-naymz"
|
129
307
|
puts "\t Enables Naymz searches.\n"
|
308
|
+
puts "--enable-spoke"
|
309
|
+
puts "\t Enables Spoke searches.\n"
|
130
310
|
puts "--enable-ggroups"
|
131
311
|
puts "\t Enables Google Groups searches.\n"
|
132
312
|
puts "--enable-pgp"
|
133
313
|
puts "\t Enables PGP searches.\n"
|
134
314
|
puts "--enable-usenet"
|
135
|
-
puts "\t Enables Usenet searches.\n
|
315
|
+
puts "\t Enables Usenet searches.\n"
|
136
316
|
puts "--disable-docs"
|
137
|
-
puts "\t Disables searches inside docs.\n
|
317
|
+
puts "\t Disables searches inside docs.\n"
|
138
318
|
puts "--disable-google"
|
139
319
|
puts "\t Disables Google searches.\n"
|
140
320
|
puts "--disable-yahoo"
|
@@ -147,6 +327,8 @@ opts.each do |opt, arg|
|
|
147
327
|
puts "\t Disables Google Profiles searches.\n"
|
148
328
|
puts "--disable-naymz"
|
149
329
|
puts "\t Disables Naymz searches.\n"
|
330
|
+
puts "--disable-spoke"
|
331
|
+
puts "\t Disables Spoke searches.\n"
|
150
332
|
puts "--disable-ggroups"
|
151
333
|
puts "\t Disables Google Groups searches.\n"
|
152
334
|
puts "--disable-pgp"
|
@@ -253,178 +435,7 @@ opts.each do |opt, arg|
|
|
253
435
|
end
|
254
436
|
end
|
255
437
|
|
256
|
-
|
257
|
-
def configure(maxhits = nil, yahoo_key = nil, bing_key = nil)
|
258
|
-
File.open(ENV['HOME'] + "/.esearchyrc", "w" ) do |line|
|
259
|
-
line << "MAXHITS=#{maxhits.to_s || "500"}\n"
|
260
|
-
line << "YAHOOKEY=#{yahoo_key.to_s}\n" if yahoo_key
|
261
|
-
line << "BINGKEY=#{bing_key.to_s}\n" if bing_key
|
262
|
-
end
|
263
|
-
end
|
264
|
-
|
265
|
-
def read_conf
|
266
|
-
File.open(ENV['HOME'] + "/.esearchyrc").readlines.each do |line|
|
267
|
-
key, value = line.split("=")
|
268
|
-
case key
|
269
|
-
when "MAXHITS" then
|
270
|
-
@params[:maxhits] ||= value.to_i
|
271
|
-
when "YAHOOKEY" then
|
272
|
-
@yahoo_key ||= value
|
273
|
-
when "BINGKEY" then
|
274
|
-
@bing_key ||= value
|
275
|
-
end
|
276
|
-
end
|
277
|
-
end
|
278
|
-
|
279
|
-
def dump(results)
|
280
|
-
# this is for session handling.
|
281
|
-
end
|
282
|
-
|
283
|
-
### PRINTING FINDING METHODS ###
|
284
|
-
def print_(list)
|
285
|
-
unless list.nil?
|
286
|
-
list.each do |item|
|
287
|
-
case item
|
288
|
-
when String
|
289
|
-
case RUBY_PLATFORM
|
290
|
-
when /mingw|mswin/
|
291
|
-
print_windows(item)
|
292
|
-
when /linux|darwin/
|
293
|
-
print_linux(item)
|
294
|
-
end
|
295
|
-
when Array
|
296
|
-
puts item.join " "
|
297
|
-
end
|
298
|
-
end
|
299
|
-
end
|
300
|
-
end
|
301
|
-
|
302
|
-
def print_linux(email)
|
303
|
-
if email.match(/#{ESearchy::Search.query.gsub("@","").split('.')[0]}/i)
|
304
|
-
puts "\033[31m" + email + "\033\[0m"
|
305
|
-
else
|
306
|
-
puts "\033[32m" + email + "\033\[0m"
|
307
|
-
end
|
308
|
-
end
|
309
|
-
|
310
|
-
def print_windows(email)
|
311
|
-
if email.match(/#{ESearchy::Search.query.gsub("@","").split('.')[0]}/i)
|
312
|
-
Wcol.puts(12, email)
|
313
|
-
else
|
314
|
-
Wcol.puts(2, email)
|
315
|
-
end
|
316
|
-
end
|
317
|
-
|
318
|
-
### SAVING TO DISK ###
|
319
|
-
class Output
|
320
|
-
def initialize(name)
|
321
|
-
@output = name
|
322
|
-
end
|
323
|
-
|
324
|
-
def save(data)
|
325
|
-
case @output
|
326
|
-
when /pdf/
|
327
|
-
save_pdf
|
328
|
-
when /csv/
|
329
|
-
save_csv
|
330
|
-
when /sqlite/
|
331
|
-
save_sqlite
|
332
|
-
end
|
333
|
-
end
|
334
|
-
|
335
|
-
private
|
336
|
-
def save_csv(data)
|
337
|
-
out = File.new(name, "w")
|
338
|
-
out << "EMAILS/PERSON, TYPE, CLASS, MATCH\n"
|
339
|
-
data.each { |r| out << r.each { |x| x }}
|
340
|
-
end
|
341
|
-
|
342
|
-
def save_pdf(data)
|
343
|
-
require 'prawn'
|
344
|
-
require 'prawn/layout'
|
345
|
-
|
346
|
-
Prawn::Document.generate(name) do
|
347
|
-
table data,
|
348
|
-
:position => :center,
|
349
|
-
:headers => ["Email/Person", "Type", "Class", "Match"],
|
350
|
-
:header_color => "0046f9",
|
351
|
-
:row_colors => :pdf_writer, #["ffffff","ffff00"],
|
352
|
-
:font_size => 10,
|
353
|
-
:vertical_padding => 2,
|
354
|
-
:horizontal_padding => 5
|
355
|
-
end
|
356
|
-
end
|
357
|
-
|
358
|
-
def save_sqlite(data)
|
359
|
-
require 'sqlite3'
|
360
|
-
@db = SQLite3::Database.new(file)
|
361
|
-
@db.execute("CREATE TABLE IF NOT EXISTS results (
|
362
|
-
id integer primary key asc,
|
363
|
-
object text,
|
364
|
-
type char,
|
365
|
-
class text,
|
366
|
-
match char);")
|
367
|
-
|
368
|
-
@results.each do |r|
|
369
|
-
@db.execute("INTERT INTO results (object,type,class,match)
|
370
|
-
VALUES (#{r[0].to_s},#{r[1]},#{r[2]},#{r[3]});")
|
371
|
-
end
|
372
|
-
@db.commit
|
373
|
-
end
|
374
|
-
end
|
375
|
-
|
376
|
-
def execute(p)
|
377
|
-
if p[:query]
|
378
|
-
search = ESearchy::Search.new(p)
|
379
|
-
|
380
|
-
search.start do |s|
|
381
|
-
unless @email_engines.empty?
|
382
|
-
s.Emails(@email_engines) do |e|
|
383
|
-
e.Yahoo.appid= @yahoo_key if @yahoo_key and @email_engines.include?(:Yahoo)
|
384
|
-
e.Bing.appid= @bing_key if @bing_key and @email_engines.include?(:Bing)
|
385
|
-
e.search do |x|
|
386
|
-
dump(x.results)
|
387
|
-
print_(x.emails.uniq)
|
388
|
-
end
|
389
|
-
if @docs
|
390
|
-
e.docs do |x|
|
391
|
-
dump(x.results)
|
392
|
-
print_(x.emails.uniq)
|
393
|
-
end
|
394
|
-
end
|
395
|
-
end
|
396
|
-
end
|
397
|
-
|
398
|
-
unless @people_engines.empty?
|
399
|
-
s.People(@people_engines) do |p|
|
400
|
-
p.search { |p| dump(p.results) }
|
401
|
-
end
|
402
|
-
end
|
403
|
-
end
|
404
|
-
@output.save(search.results) if @output
|
405
|
-
puts "-------FINAL RESULTS--------"
|
406
|
-
print_ search.emails
|
407
|
-
print_ search.people
|
408
|
-
end
|
409
|
-
end
|
410
|
-
if RUBY_PLATFORM =~ /mingw|mswin/
|
411
|
-
puts "___________ _________ .__ "
|
412
|
-
puts "\_ _____// _____/ ____ _____ _______ ____ | |__ ___.__."
|
413
|
-
puts " | __)_ \_____ \_/ __ \\__ \\_ __ \_/ ___\| | < | |"
|
414
|
-
puts " | \/ \ ___/ / __ \| | \/\ \___| Y \___ |"
|
415
|
-
puts "/_______ /_______ /\___ >____ /__| \___ >___| / ____|"
|
416
|
-
puts " \/ \/ \/ \/ \/ \/\/ "
|
417
|
-
else
|
418
|
-
puts "\033[31m___________ \033\[0m_________ .__ "
|
419
|
-
puts "\033[31m\\_ _____/\033\[0m/ _____/ ____ _____ _______ ____ | |__ ___.__."
|
420
|
-
puts "\033[31m | __)_ \033\[0m\\_____ \\_/ __ \\\\__ \\\\_ __ \\_/ ___\\| | < | |"
|
421
|
-
puts "\033[31m | \\\033\[0m/ \\ ___/ / __ \\| | \\/\\ \\___| Y \\___ |"
|
422
|
-
puts "\033[31m/_______ /\033\[0m_______ /\\___ >____ /__| \___ >___| / ____|"
|
423
|
-
puts "\033[31m \\/\033\[0m \\/ \\/ \\/ \\/ \\/\\/"
|
424
|
-
end
|
425
|
-
puts "\n"
|
426
|
-
puts "DISCLOSURE: This is just an example tool for the library. ESearchy is intended
|
427
|
-
to work as a Library/Framework and you should create your own scripts :)"
|
438
|
+
logo
|
428
439
|
puts "------------------------------------------------------------------------"
|
429
440
|
puts "REMINDER:"
|
430
441
|
puts "- if you want to use GoogleProfiles, LinkedIn, Classmates or Naymz,"
|
data/lib/esearchy/esearchy.rb
CHANGED
@@ -58,6 +58,10 @@ module ESearchy
|
|
58
58
|
end
|
59
59
|
rescue Net::HTTPFatalError
|
60
60
|
D "Error: Something went wrong with the HTTP request"
|
61
|
+
rescue Net::HTTPServerException
|
62
|
+
D "Error: Something went wrong with the HTTP request"
|
63
|
+
rescue
|
64
|
+
D "Error: Something went wrong :("
|
61
65
|
end
|
62
66
|
end
|
63
67
|
|
@@ -133,7 +137,7 @@ module ESearchy
|
|
133
137
|
@emails.concat(c_list).uniq!
|
134
138
|
c_list.zip do |e|
|
135
139
|
@results << [e[0], "E", self.class.to_s.upcase,
|
136
|
-
|
140
|
+
e[0].downcase.match(/#{CGI.unescape(@query).gsub("@","").split('.')[0]}/) ? "T" : "F"]
|
137
141
|
end
|
138
142
|
end
|
139
143
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: esearchy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.0.
|
4
|
+
version: 0.2.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matias P. Brutti
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2010-
|
12
|
+
date: 2010-02-21 00:00:00 -03:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|