-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun.rb
More file actions
25 lines (20 loc) · 714 Bytes
/
run.rb
File metadata and controls
25 lines (20 loc) · 714 Bytes
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
# coding: utf-8
require_relative './crawler'
require 'csv'
DEFAULT_OPTIONS={
base_url: 'https://news.ycombinator.com/',
requested_rows: 30
}
puts 'Scraping'
ycrawler = Crawler.new(DEFAULT_OPTIONS[:base_url])
ycrawler.fetch(DEFAULT_OPTIONS[:requested_rows])
puts ycrawler.entries
puts '--------------------------------------'
puts 'Filtering words less than 5'
puts ycrawler.words_less_than(5,:points).count
puts ycrawler.words_less_than(5,:points)
puts '--------------------------------------'
puts 'Filtering words more than 5'
puts ycrawler.words_more_than(5,:comments).count
puts ycrawler.words_more_than(5,:comments)
CSV.open('reserved.csv', 'w') { |csv| csv << ycrawler.entries }