-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRakefile
38 lines (28 loc) · 787 Bytes
/
Rakefile
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
require "bundler/gem_tasks"
require "rspec/core/rake_task"
require 'mechanizer'
RSpec::Core::RakeTask.new(:spec)
task :default => :spec
task :test => :spec
###################
task :console do
require 'irb'
require 'irb/completion'
require 'mechanizer'
require "active_support/all"
ARGV.clear
# noko_page_hash = run_mechanizer
# binding.pry
IRB.start
end
def run_mechanizer
noko = Mechanizer::Noko.new
args = {url: 'https://www.wikipedia.org', timeout: 30}
# args = {url: 'wikipedia', timeout: 30}
noko_hash = noko.scrape(args)
err_msg = noko_hash[:err_msg]
page = noko_hash[:page]
texts_and_paths = noko_hash[:texts_and_paths]
other_projects = page.css('.other-project')&.text
other_projects = other_projects.split("\n").reject(&:blank?)
end