-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.rb
More file actions
42 lines (34 loc) · 1.07 KB
/
main.rb
File metadata and controls
42 lines (34 loc) · 1.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
require './mech'
# require './water'
def run
# assume that on startup main will be ran once to wipe previous logs
unless ARGV[0]
puts "this is our input field >>> #{ARGV}"
puts "wipe our previous logs #{File.open('mech.log', 'w') { |file| file.truncate(0) }}"
puts 'try the following command:'
puts 'bundle exec ruby main.rb scrape https://www.coolmathgames.com/'
end
if ARGV[0] == 'links'
parselinks = Gen_mech.new(ARGV[1..], 1, cookies = true)
puts parselinks.parse_for_links
end
if ARGV[0] == 'scrape'
parseprices = Gen_mech.new([ARGV[1]], 1, cookies = true)
# check if class is a string input
if ARGV[3]
if ARGV[3] == '-class'
puts parseprices.hard_parse_for_class('', ARGV[2], true)
else
puts parseprices.hard_parse_for_class(ARGV[2], ARGV[3], false)
end
else
# puts 'no extra args or arg is tag'
puts parseprices.hard_parse_for_class(ARGV[2], '', false)
end
end
if ARGV[0] == 'water'
waterbot = Gen_watir.new(ARGV[1..])
resolve_water = waterbot.base_test
end
end
run