Class: Strigil

Inherits:
Object
  • Object
show all
Defined in:
lib/strigil.rb

Defined Under Namespace

Classes: Comment, Comments, CommentsParser, StrigilClient

Class Method Summary collapse

Class Method Details

.engage(user) ⇒ Object



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
# File 'lib/strigil.rb', line 2

def self.engage(user)
  client_config

  puts "Initializing client..."
  client = Strigil::StrigilClient.new(
    username: @username,
    password: @password,
    browser: @browser,
    target: user
  )

  puts "Initializing comments store..."
  comments = Strigil::Comments.new

  puts "Beginning scrape. This may take a while."
  processing = true
  while processing == true
    comments.add_comments(client.pull_comments)

    begin
      client.iterate
    rescue EndOfQueueError
      processing = false

      client.close
      comments.save

      puts "Pulled #{comments.log.size} comments."
      puts "JSON data stored in ./data/comments.json"

      comments.clear
    end
  end
end