pointmd_comments 0.1.4 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2a8d49153c05c07e558908b1c19086c4262bc11d756bcff25e6b6bde5a910296
|
4
|
+
data.tar.gz: 2177d0c16b2081673973716b3b7234c81ac1ce381d8e1c06176b4749aca68ccf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 893a9e4361e7dad02e3de991cc7a8590137f55ce766d620a3a8fbd59a5388f0a01d7266dc341d70b03603ecb5665db7530952991387179e20cc3b7ce888b7927
|
7
|
+
data.tar.gz: 827406d9bf3c0a374645af5a8405f1a603e6fc72826c9abff692d2b1532adcad1c6c60bacace4e78adc4f698725717291f5ba3df61188839babc0030803853d0
|
@@ -1,6 +1,8 @@
|
|
1
1
|
module PointmdComments
|
2
2
|
module Aggregators
|
3
3
|
class Main
|
4
|
+
CHROME_ARGS = %w[disable-dev-shm-usage disable-software-rasterizer no-sandbox].freeze
|
5
|
+
|
4
6
|
attr_reader :posts_aggregator, :browser, :comments_aggregator, :all_comments, :posts, :source, :output, :path
|
5
7
|
|
6
8
|
def initialize(options)
|
@@ -10,7 +12,12 @@ module PointmdComments
|
|
10
12
|
@source = options[:source] || Aggregators::Posts::DEFAULT_SOURCE
|
11
13
|
@posts_aggregator = Aggregators::Posts.new(source: source, path: path)
|
12
14
|
@comments_aggregator = Aggregators::Comments.new
|
13
|
-
|
15
|
+
|
16
|
+
client = Selenium::WebDriver::Remote::Http::Default.new
|
17
|
+
# NOTE: #timeout= is deprecated, use #read_timeout= and #open_timeout= instead
|
18
|
+
client.timeout = 600 # instead of the default 60 (seconds)
|
19
|
+
|
20
|
+
@browser = ::Watir::Browser.new :chrome, http_client: client, headless: true, args: CHROME_ARGS
|
14
21
|
@all_comments = []
|
15
22
|
end
|
16
23
|
|
@@ -46,7 +53,9 @@ module PointmdComments
|
|
46
53
|
end
|
47
54
|
|
48
55
|
def write_to_csv
|
49
|
-
|
56
|
+
# File#expand_path is needed to process paths like '~/test.txt' => '/Users/me/test.txt'
|
57
|
+
file_path = File.expand_path(output)
|
58
|
+
puts "File Path is #{file_path}"
|
50
59
|
|
51
60
|
CSV.open(file_path, 'w') do |csv|
|
52
61
|
all_comments.each { |c| csv << c }
|
@@ -11,7 +11,6 @@ module PointmdComments
|
|
11
11
|
def initialize(source:, path:)
|
12
12
|
@source = source
|
13
13
|
@path = path
|
14
|
-
@urls = []
|
15
14
|
end
|
16
15
|
|
17
16
|
def call
|
@@ -41,22 +40,14 @@ module PointmdComments
|
|
41
40
|
end
|
42
41
|
|
43
42
|
def fetch_news_posts
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
def populate_urls(main_post, other_posts)
|
54
|
-
@urls << main_post
|
55
|
-
|
56
|
-
@urls += other_posts.children.map do |child|
|
57
|
-
child.css('article').css('h2').children[1]['href']
|
58
|
-
rescue StandardError
|
59
|
-
next
|
43
|
+
# NOTE: .post-blocks-wrap does not exist anymore
|
44
|
+
# Find <article> tags instead
|
45
|
+
articles = @page.css('article')
|
46
|
+
|
47
|
+
@urls = articles.map do |article|
|
48
|
+
article.css('a').last.attribute('href').to_s
|
49
|
+
rescue StandardError => e
|
50
|
+
puts e
|
60
51
|
end.compact
|
61
52
|
end
|
62
53
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pointmd_comments
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nicolai Stoianov
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-04-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: pry
|
@@ -120,7 +120,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
120
120
|
- !ruby/object:Gem::Version
|
121
121
|
version: '0'
|
122
122
|
requirements: []
|
123
|
-
rubygems_version: 3.
|
123
|
+
rubygems_version: 3.2.3
|
124
124
|
signing_key:
|
125
125
|
specification_version: 4
|
126
126
|
summary: Point.md comments aggregator
|