forki 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.github/workflows/main.yml +18 -0
- data/.gitignore +17 -0
- data/.rubocop.yml +71 -0
- data/.ruby-version +1 -0
- data/CHANGELOG.md +5 -0
- data/CODE_OF_CONDUCT.md +84 -0
- data/Gemfile +21 -0
- data/Gemfile.lock +163 -0
- data/LICENSE.txt +21 -0
- data/README.md +87 -0
- data/Rakefile +16 -0
- data/bin/console +15 -0
- data/bin/setup +8 -0
- data/forki.gemspec +42 -0
- data/lib/forki/post.rb +61 -0
- data/lib/forki/scrapers/post_scraper.rb +360 -0
- data/lib/forki/scrapers/scraper.rb +189 -0
- data/lib/forki/scrapers/user_scraper.rb +94 -0
- data/lib/forki/user.rb +45 -0
- data/lib/forki/version.rb +5 -0
- data/lib/forki.rb +98 -0
- data/lib/generators/forki.rb +3 -0
- data/lib/generators/forki_generator.rb +6 -0
- data/lib/helpers/configuration.rb +28 -0
- data/reactions/.DS_Store +0 -0
- data/reactions/angry.png +0 -0
- data/reactions/care.png +0 -0
- data/reactions/haha.png +0 -0
- data/reactions/like.png +0 -0
- data/reactions/love.png +0 -0
- data/reactions/pride.png +0 -0
- data/reactions/sad.png +0 -0
- data/reactions/wow.png +0 -0
- metadata +146 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: cb9eb80820ccf86f9a99d1c757940a935137d834a2bd76d855deaeee470840a1
|
4
|
+
data.tar.gz: 667f0600afdf53ced62b57def3021a6ccc0cf2a194142e2f23beb76c8384a35a
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 78aa5d9bf07a1f5790f8e1705056956b30a7d2854723b74fdfd0a7612be2c3988916333bfc5fc15dff62d62fda1d01452f375765b4e1ddc6633148372993ebbb
|
7
|
+
data.tar.gz: 21d6c81749a1f1fe160508e9efe53ca6abc2be59b01eb31684a500df79b9092647de47d1545ea21c0c701c5d1e34f2f40c35dcf0765bdfce6d7c72ec60feee2b
|
@@ -0,0 +1,18 @@
|
|
1
|
+
name: Ruby
|
2
|
+
|
3
|
+
on: [push,pull_request]
|
4
|
+
|
5
|
+
jobs:
|
6
|
+
build:
|
7
|
+
runs-on: ubuntu-latest
|
8
|
+
steps:
|
9
|
+
- uses: actions/checkout@v2
|
10
|
+
- name: Set up Ruby
|
11
|
+
uses: ruby/setup-ruby@v1
|
12
|
+
with:
|
13
|
+
ruby-version: 3.1.2
|
14
|
+
- name: Run the default task
|
15
|
+
run: |
|
16
|
+
gem install bundler -v 2.2.14
|
17
|
+
bundle install
|
18
|
+
rubocop
|
data/.gitignore
ADDED
data/.rubocop.yml
ADDED
@@ -0,0 +1,71 @@
|
|
1
|
+
require:
|
2
|
+
- rubocop-rails
|
3
|
+
|
4
|
+
inherit_gem:
|
5
|
+
rubocop-rails_config:
|
6
|
+
- config/rails.yml
|
7
|
+
|
8
|
+
AllCops:
|
9
|
+
Exclude:
|
10
|
+
- db/schema.rb
|
11
|
+
- 'node_modules/**/*'
|
12
|
+
- 'redis-stable/**/*'
|
13
|
+
- 'bin/**/*'
|
14
|
+
- 'vendor/**/*'
|
15
|
+
TargetRubyVersion: 3.0
|
16
|
+
|
17
|
+
# Rails generates this file
|
18
|
+
Style/BlockComments:
|
19
|
+
Exclude:
|
20
|
+
- 'db/seeds.rb'
|
21
|
+
|
22
|
+
# Require hash values to be explicitly set
|
23
|
+
Style/HashSyntax:
|
24
|
+
Enabled: false
|
25
|
+
|
26
|
+
# This sets us to use the standard Rails format instead of Rubocop's
|
27
|
+
# opinionated Ruby style.
|
28
|
+
Style/FrozenStringLiteralComment:
|
29
|
+
Enabled: false
|
30
|
+
|
31
|
+
# This sets us to use the standard Rails format instead of Rubocop's
|
32
|
+
# opinionated Ruby style.
|
33
|
+
Style/ClassAndModuleChildren:
|
34
|
+
Enabled: false
|
35
|
+
|
36
|
+
# Rails generates this file
|
37
|
+
Layout/IndentationStyle:
|
38
|
+
Exclude:
|
39
|
+
- 'db/seeds.rb'
|
40
|
+
|
41
|
+
# Temporarily turn this off
|
42
|
+
Metrics/AbcSize:
|
43
|
+
Enabled: false
|
44
|
+
|
45
|
+
Metrics/ClassLength:
|
46
|
+
Enabled: true
|
47
|
+
|
48
|
+
Lint/RescueException:
|
49
|
+
Enabled: true
|
50
|
+
|
51
|
+
Lint/Debugger:
|
52
|
+
Enabled: true
|
53
|
+
|
54
|
+
Rails/HasManyOrHasOneDependent:
|
55
|
+
Enabled: true
|
56
|
+
|
57
|
+
Rails/HasAndBelongsToMany:
|
58
|
+
Enabled: true
|
59
|
+
|
60
|
+
Style/NumericPredicate:
|
61
|
+
Enabled: true
|
62
|
+
|
63
|
+
# This sets us to use the standard Rails format instead of Rubocop's
|
64
|
+
# opinionated Ruby style.
|
65
|
+
Layout/EmptyLinesAroundAccessModifier:
|
66
|
+
Enabled: true
|
67
|
+
EnforcedStyle: 'around'
|
68
|
+
|
69
|
+
# We're not a Rails app, just using their style sheet
|
70
|
+
Rails/AssertNot:
|
71
|
+
Enabled: false
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
3.1.4
|
data/CHANGELOG.md
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,84 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.
|
6
|
+
|
7
|
+
We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.
|
8
|
+
|
9
|
+
## Our Standards
|
10
|
+
|
11
|
+
Examples of behavior that contributes to a positive environment for our community include:
|
12
|
+
|
13
|
+
* Demonstrating empathy and kindness toward other people
|
14
|
+
* Being respectful of differing opinions, viewpoints, and experiences
|
15
|
+
* Giving and gracefully accepting constructive feedback
|
16
|
+
* Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience
|
17
|
+
* Focusing on what is best not just for us as individuals, but for the overall community
|
18
|
+
|
19
|
+
Examples of unacceptable behavior include:
|
20
|
+
|
21
|
+
* The use of sexualized language or imagery, and sexual attention or
|
22
|
+
advances of any kind
|
23
|
+
* Trolling, insulting or derogatory comments, and personal or political attacks
|
24
|
+
* Public or private harassment
|
25
|
+
* Publishing others' private information, such as a physical or email
|
26
|
+
address, without their explicit permission
|
27
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
28
|
+
professional setting
|
29
|
+
|
30
|
+
## Enforcement Responsibilities
|
31
|
+
|
32
|
+
Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful.
|
33
|
+
|
34
|
+
Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate.
|
35
|
+
|
36
|
+
## Scope
|
37
|
+
|
38
|
+
This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event.
|
39
|
+
|
40
|
+
## Enforcement
|
41
|
+
|
42
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at cguess@gmail.com. All complaints will be reviewed and investigated promptly and fairly.
|
43
|
+
|
44
|
+
All community leaders are obligated to respect the privacy and security of the reporter of any incident.
|
45
|
+
|
46
|
+
## Enforcement Guidelines
|
47
|
+
|
48
|
+
Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct:
|
49
|
+
|
50
|
+
### 1. Correction
|
51
|
+
|
52
|
+
**Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community.
|
53
|
+
|
54
|
+
**Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested.
|
55
|
+
|
56
|
+
### 2. Warning
|
57
|
+
|
58
|
+
**Community Impact**: A violation through a single incident or series of actions.
|
59
|
+
|
60
|
+
**Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban.
|
61
|
+
|
62
|
+
### 3. Temporary Ban
|
63
|
+
|
64
|
+
**Community Impact**: A serious violation of community standards, including sustained inappropriate behavior.
|
65
|
+
|
66
|
+
**Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban.
|
67
|
+
|
68
|
+
### 4. Permanent Ban
|
69
|
+
|
70
|
+
**Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals.
|
71
|
+
|
72
|
+
**Consequence**: A permanent ban from any sort of public interaction within the community.
|
73
|
+
|
74
|
+
## Attribution
|
75
|
+
|
76
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.0,
|
77
|
+
available at https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
|
78
|
+
|
79
|
+
Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity).
|
80
|
+
|
81
|
+
[homepage]: https://www.contributor-covenant.org
|
82
|
+
|
83
|
+
For answers to common questions about this code of conduct, see the FAQ at
|
84
|
+
https://www.contributor-covenant.org/faq. Translations are available at https://www.contributor-covenant.org/translations.
|
data/Gemfile
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
source "https://rubygems.org"
|
4
|
+
|
5
|
+
# Specify your gem's dependencies in birdsong.gemspec
|
6
|
+
gemspec
|
7
|
+
|
8
|
+
gem "rake", "~> 13.0"
|
9
|
+
|
10
|
+
gem "minitest", "~> 5.0"
|
11
|
+
|
12
|
+
gem "rubocop", "~> 1.7"
|
13
|
+
|
14
|
+
gem "rubocop-rails", "~> 2.17.3", require: false # Rails specific styles
|
15
|
+
gem "rubocop-rails_config"
|
16
|
+
|
17
|
+
gem "dotenv", "~> 2.7.6"
|
18
|
+
|
19
|
+
gem "byebug"
|
20
|
+
|
21
|
+
gem "rack", "2.2.4"
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,163 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
forki (0.1.0)
|
5
|
+
apparition
|
6
|
+
capybara
|
7
|
+
oj
|
8
|
+
selenium-webdriver
|
9
|
+
typhoeus
|
10
|
+
|
11
|
+
GEM
|
12
|
+
remote: https://rubygems.org/
|
13
|
+
specs:
|
14
|
+
actionpack (7.0.4.3)
|
15
|
+
actionview (= 7.0.4.3)
|
16
|
+
activesupport (= 7.0.4.3)
|
17
|
+
rack (~> 2.0, >= 2.2.0)
|
18
|
+
rack-test (>= 0.6.3)
|
19
|
+
rails-dom-testing (~> 2.0)
|
20
|
+
rails-html-sanitizer (~> 1.0, >= 1.2.0)
|
21
|
+
actionview (7.0.4.3)
|
22
|
+
activesupport (= 7.0.4.3)
|
23
|
+
builder (~> 3.1)
|
24
|
+
erubi (~> 1.4)
|
25
|
+
rails-dom-testing (~> 2.0)
|
26
|
+
rails-html-sanitizer (~> 1.1, >= 1.2.0)
|
27
|
+
activesupport (7.0.4.3)
|
28
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
29
|
+
i18n (>= 1.6, < 2)
|
30
|
+
minitest (>= 5.1)
|
31
|
+
tzinfo (~> 2.0)
|
32
|
+
addressable (2.8.4)
|
33
|
+
public_suffix (>= 2.0.2, < 6.0)
|
34
|
+
apparition (0.6.0)
|
35
|
+
capybara (~> 3.13, < 4)
|
36
|
+
websocket-driver (>= 0.6.5)
|
37
|
+
ast (2.4.2)
|
38
|
+
builder (3.2.4)
|
39
|
+
byebug (11.1.3)
|
40
|
+
capybara (3.39.1)
|
41
|
+
addressable
|
42
|
+
matrix
|
43
|
+
mini_mime (>= 0.1.3)
|
44
|
+
nokogiri (~> 1.8)
|
45
|
+
rack (>= 1.6.0)
|
46
|
+
rack-test (>= 0.6.3)
|
47
|
+
regexp_parser (>= 1.5, < 3.0)
|
48
|
+
xpath (~> 3.2)
|
49
|
+
concurrent-ruby (1.2.2)
|
50
|
+
crass (1.0.6)
|
51
|
+
dotenv (2.7.6)
|
52
|
+
erubi (1.12.0)
|
53
|
+
ethon (0.16.0)
|
54
|
+
ffi (>= 1.15.0)
|
55
|
+
ffi (1.15.5)
|
56
|
+
i18n (1.13.0)
|
57
|
+
concurrent-ruby (~> 1.0)
|
58
|
+
json (2.6.3)
|
59
|
+
loofah (2.21.3)
|
60
|
+
crass (~> 1.0.2)
|
61
|
+
nokogiri (>= 1.12.0)
|
62
|
+
matrix (0.4.2)
|
63
|
+
method_source (1.0.0)
|
64
|
+
mini_mime (1.1.2)
|
65
|
+
minitest (5.18.0)
|
66
|
+
nokogiri (1.15.1-arm64-darwin)
|
67
|
+
racc (~> 1.4)
|
68
|
+
oj (3.14.3)
|
69
|
+
parallel (1.23.0)
|
70
|
+
parser (3.2.2.1)
|
71
|
+
ast (~> 2.4.1)
|
72
|
+
public_suffix (5.0.1)
|
73
|
+
racc (1.6.2)
|
74
|
+
rack (2.2.4)
|
75
|
+
rack-test (2.1.0)
|
76
|
+
rack (>= 1.3)
|
77
|
+
rails-dom-testing (2.0.3)
|
78
|
+
activesupport (>= 4.2.0)
|
79
|
+
nokogiri (>= 1.6)
|
80
|
+
rails-html-sanitizer (1.5.0)
|
81
|
+
loofah (~> 2.19, >= 2.19.1)
|
82
|
+
railties (7.0.4.3)
|
83
|
+
actionpack (= 7.0.4.3)
|
84
|
+
activesupport (= 7.0.4.3)
|
85
|
+
method_source
|
86
|
+
rake (>= 12.2)
|
87
|
+
thor (~> 1.0)
|
88
|
+
zeitwerk (~> 2.5)
|
89
|
+
rainbow (3.1.1)
|
90
|
+
rake (13.0.6)
|
91
|
+
regexp_parser (2.8.0)
|
92
|
+
rexml (3.2.5)
|
93
|
+
rubocop (1.51.0)
|
94
|
+
json (~> 2.3)
|
95
|
+
parallel (~> 1.10)
|
96
|
+
parser (>= 3.2.0.0)
|
97
|
+
rainbow (>= 2.2.2, < 4.0)
|
98
|
+
regexp_parser (>= 1.8, < 3.0)
|
99
|
+
rexml (>= 3.2.5, < 4.0)
|
100
|
+
rubocop-ast (>= 1.28.0, < 2.0)
|
101
|
+
ruby-progressbar (~> 1.7)
|
102
|
+
unicode-display_width (>= 2.4.0, < 3.0)
|
103
|
+
rubocop-ast (1.28.1)
|
104
|
+
parser (>= 3.2.1.0)
|
105
|
+
rubocop-md (1.2.0)
|
106
|
+
rubocop (>= 1.0)
|
107
|
+
rubocop-minitest (0.31.0)
|
108
|
+
rubocop (>= 1.39, < 2.0)
|
109
|
+
rubocop-packaging (0.5.2)
|
110
|
+
rubocop (>= 1.33, < 2.0)
|
111
|
+
rubocop-performance (1.18.0)
|
112
|
+
rubocop (>= 1.7.0, < 2.0)
|
113
|
+
rubocop-ast (>= 0.4.0)
|
114
|
+
rubocop-rails (2.17.4)
|
115
|
+
activesupport (>= 4.2.0)
|
116
|
+
rack (>= 1.1)
|
117
|
+
rubocop (>= 1.33.0, < 2.0)
|
118
|
+
rubocop-rails_config (1.13.0)
|
119
|
+
railties (>= 5.0)
|
120
|
+
rubocop (>= 1.48.0)
|
121
|
+
rubocop-ast (>= 1.26.0)
|
122
|
+
rubocop-md
|
123
|
+
rubocop-minitest (~> 0.22)
|
124
|
+
rubocop-packaging (~> 0.5)
|
125
|
+
rubocop-performance (~> 1.11)
|
126
|
+
rubocop-rails (~> 2.0)
|
127
|
+
ruby-progressbar (1.13.0)
|
128
|
+
rubyzip (2.3.2)
|
129
|
+
selenium-webdriver (4.9.1)
|
130
|
+
rexml (~> 3.2, >= 3.2.5)
|
131
|
+
rubyzip (>= 1.2.2, < 3.0)
|
132
|
+
websocket (~> 1.0)
|
133
|
+
thor (1.2.2)
|
134
|
+
typhoeus (1.4.0)
|
135
|
+
ethon (>= 0.9.0)
|
136
|
+
tzinfo (2.0.6)
|
137
|
+
concurrent-ruby (~> 1.0)
|
138
|
+
unicode-display_width (2.4.2)
|
139
|
+
websocket (1.2.9)
|
140
|
+
websocket-driver (0.7.5)
|
141
|
+
websocket-extensions (>= 0.1.0)
|
142
|
+
websocket-extensions (0.1.5)
|
143
|
+
xpath (3.2.0)
|
144
|
+
nokogiri (~> 1.8)
|
145
|
+
zeitwerk (2.6.8)
|
146
|
+
|
147
|
+
PLATFORMS
|
148
|
+
arm64-darwin-21
|
149
|
+
arm64-darwin-22
|
150
|
+
|
151
|
+
DEPENDENCIES
|
152
|
+
byebug
|
153
|
+
dotenv (~> 2.7.6)
|
154
|
+
forki!
|
155
|
+
minitest (~> 5.0)
|
156
|
+
rack (= 2.2.4)
|
157
|
+
rake (~> 13.0)
|
158
|
+
rubocop (~> 1.7)
|
159
|
+
rubocop-rails (~> 2.17.3)
|
160
|
+
rubocop-rails_config
|
161
|
+
|
162
|
+
BUNDLED WITH
|
163
|
+
2.3.11
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2021 Christopher Guess
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,87 @@
|
|
1
|
+
# forki
|
2
|
+
|
3
|
+
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/forki`. To experiment with that code, run `bin/console` for an interactive prompt.
|
4
|
+
|
5
|
+
TODO: Delete this and the text above, and describe your gem
|
6
|
+
|
7
|
+
## Pre Reqs
|
8
|
+
|
9
|
+
This requires the chromedriver
|
10
|
+
|
11
|
+
### MacOS
|
12
|
+
|
13
|
+
`brew install chromedriver`
|
14
|
+
|
15
|
+
### Raspberry OS (aka Rasbian / Debian)
|
16
|
+
Since this requires ARMHF support it's not through regular sources. However, the maintainers of Raspberry OS has made their own!
|
17
|
+
`sudo apt install chromium-chromedriver`
|
18
|
+
|
19
|
+
### Debian/Ubuntu
|
20
|
+
`sudo apt install chromedriver` (should work)
|
21
|
+
|
22
|
+
## Installation
|
23
|
+
|
24
|
+
Add this line to your application's Gemfile:
|
25
|
+
|
26
|
+
```ruby
|
27
|
+
gem "forki"
|
28
|
+
```
|
29
|
+
|
30
|
+
And then execute:
|
31
|
+
|
32
|
+
$ bundle install
|
33
|
+
|
34
|
+
Or install it yourself as:
|
35
|
+
|
36
|
+
$ gem install forki
|
37
|
+
|
38
|
+
### Selenium standalone
|
39
|
+
|
40
|
+
We use Selenium's standalone package. To set it up:
|
41
|
+
|
42
|
+
1. Download the "Selenium Server (Grid)" JAR package at https://www.selenium.dev/downloads/
|
43
|
+
2. Save it to the folder of this package
|
44
|
+
3. Test that it works by running `java -jar ./selenium-server-4.2.1.jar standalone --session-timeout 1000` (note the actual version you downloaded)
|
45
|
+
|
46
|
+
## Testing
|
47
|
+
|
48
|
+
1. Turn on the Selenium server `java -jar ./selenium-server-4.2.1.jar standalone --session-timeout 1000` in a separate pane or window
|
49
|
+
2. `rake test`
|
50
|
+
|
51
|
+
## Debugging
|
52
|
+
|
53
|
+
This scraper is prone to break pretty often due to Facebook's GraphQL schema being pretty damn unstable.
|
54
|
+
Whether this is malevolent (to purposely break scrapers) or just happening in the course of development is undetermined and really, doesn't matter.
|
55
|
+
|
56
|
+
Debugging this is a bit of a pain, but I'm laying out a few steps to start at and make this easier.
|
57
|
+
Some of this may sound basic, but it's good to keep it all in mind.
|
58
|
+
|
59
|
+
1. Run the tests `rake test` and note the line where everything is breaking. If the tests consistently fail on a single line, Facebook has likely changed the schema for a certain type of media (e.g., live videos, page photos).
|
60
|
+
2. Set a debug point at the top of the function where the failures are occurring. Step through the the code as it extracts GraphQL objects. If you find that one of the extracted objects is `nil`, you've discovered the place where Facebook has changed its schema and which GraphQL object we no longer have access to.
|
61
|
+
3. Find a new place to extract the Facebook post/user attributes we used to grab from the now-missing GraphQL object. Try grepping through the `graphql_strings` array to find the key of the attribute you need to grab data for.
|
62
|
+
4. Repeat step 3 for each attribute we used to draw from the GraphQL object identified in step 2.
|
63
|
+
5. Trust the tests, run them over and over, modifying as little about the rest of the code as possible,
|
64
|
+
otherwise you may end up changing the structure of everything, we don't want that.
|
65
|
+
6. Ask Chris or Asa if you have questions.
|
66
|
+
|
67
|
+
## Usage
|
68
|
+
|
69
|
+
TODO: Write usage instructions here
|
70
|
+
|
71
|
+
## Development
|
72
|
+
|
73
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
74
|
+
|
75
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
76
|
+
|
77
|
+
## Contributing
|
78
|
+
|
79
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/forki. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/forki/blob/master/CODE_OF_CONDUCT.md).
|
80
|
+
|
81
|
+
## License
|
82
|
+
|
83
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
84
|
+
|
85
|
+
## Code of Conduct
|
86
|
+
|
87
|
+
Everyone interacting in the forki project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/forki/blob/master/CODE_OF_CONDUCT.md).
|
data/Rakefile
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "bundler/gem_tasks"
|
4
|
+
require "rake/testtask"
|
5
|
+
require "rubocop/rake_task"
|
6
|
+
|
7
|
+
Rake::TestTask.new(:test) do |t|
|
8
|
+
t.libs << "test"
|
9
|
+
t.libs << "lib"
|
10
|
+
t.test_files = FileList["test/**/*_test.rb"]
|
11
|
+
end
|
12
|
+
|
13
|
+
|
14
|
+
RuboCop::RakeTask.new
|
15
|
+
|
16
|
+
task default: %i[test rubocop]
|
data/bin/console
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require "bundler/setup"
|
5
|
+
require "forki"
|
6
|
+
|
7
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
8
|
+
# with your gem easier. You can also use a different console, if you like.
|
9
|
+
|
10
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
11
|
+
# require "pry"
|
12
|
+
# Pry.start
|
13
|
+
|
14
|
+
require "irb"
|
15
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
data/forki.gemspec
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "lib/forki/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = "forki"
|
7
|
+
spec.version = Forki::VERSION
|
8
|
+
spec.authors = [""]
|
9
|
+
spec.email = [""]
|
10
|
+
|
11
|
+
spec.summary = "A gem to scrape Facebook pages for archive purposes."
|
12
|
+
# spec.description = "TODO: Write a longer description or delete this line."
|
13
|
+
# spec.homepage = "TODO: Put your gem's website or public repo URL here."
|
14
|
+
spec.license = "MIT"
|
15
|
+
spec.required_ruby_version = Gem::Requirement.new(">= 2.7.0")
|
16
|
+
|
17
|
+
# spec.metadata["allowed_push_host"] = "TODO: Set to 'http://mygemserver.com'"
|
18
|
+
|
19
|
+
# spec.metadata["homepage_uri"] = spec.homepage
|
20
|
+
# spec.metadata["source_code_uri"] = "TODO: Put your gem's public repo URL here."
|
21
|
+
# spec.metadata["changelog_uri"] = "TODO: Put your gem's CHANGELOG.md URL here."
|
22
|
+
|
23
|
+
# Specify which files should be added to the gem when it is released.
|
24
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
25
|
+
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
26
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{\A(?:test|spec|features)/}) }
|
27
|
+
end
|
28
|
+
spec.bindir = "exe"
|
29
|
+
spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
|
30
|
+
spec.require_paths = ["lib"]
|
31
|
+
|
32
|
+
# Uncomment to register a new dependency of your gem
|
33
|
+
# spec.add_dependency "example-gem", "~> 1.0"
|
34
|
+
spec.add_dependency "capybara" # For scraping and running browsers
|
35
|
+
spec.add_dependency "apparition" # A Chrome driver for Capybara
|
36
|
+
spec.add_dependency "typhoeus" # For making API requests
|
37
|
+
spec.add_dependency "oj" # A faster JSON parser/loader than stdlib
|
38
|
+
spec.add_dependency "selenium-webdriver" # Webdriver selenium
|
39
|
+
|
40
|
+
# For more information and examples about making a new gem, checkout our
|
41
|
+
# guide at: https://bundler.io/guides/creating_gem.html
|
42
|
+
end
|
data/lib/forki/post.rb
ADDED
@@ -0,0 +1,61 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Forki
|
4
|
+
class Post
|
5
|
+
def self.lookup(urls = [])
|
6
|
+
urls = [urls] unless urls.kind_of?(Array)
|
7
|
+
self.scrape(urls)
|
8
|
+
end
|
9
|
+
|
10
|
+
attr_reader :image_file,
|
11
|
+
:image_url,
|
12
|
+
:has_video,
|
13
|
+
:url,
|
14
|
+
:id,
|
15
|
+
:num_comments,
|
16
|
+
:num_shares,
|
17
|
+
:num_views,
|
18
|
+
:reactions,
|
19
|
+
:text,
|
20
|
+
:created_at,
|
21
|
+
:user,
|
22
|
+
:video_file,
|
23
|
+
:video_preview_image_file,
|
24
|
+
:video_preview_image_url,
|
25
|
+
:screenshot_file
|
26
|
+
|
27
|
+
private
|
28
|
+
|
29
|
+
def initialize(post_hash = {})
|
30
|
+
# I need to figure out what's up with Facebook ids. Media have unique IDs, but their position in the URL is variable
|
31
|
+
# @id = post_hash[:id]
|
32
|
+
@image_file = post_hash[:image_file]
|
33
|
+
@image_url = post_hash[:image_url]
|
34
|
+
@has_video = post_hash[:has_video]
|
35
|
+
@url = post_hash[:url]
|
36
|
+
@id = post_hash[:id]
|
37
|
+
@num_comments = post_hash[:num_comments]
|
38
|
+
@num_shares = post_hash[:num_shares]
|
39
|
+
@num_views = post_hash[:num_views]
|
40
|
+
@reactions = post_hash[:reactions]
|
41
|
+
@text = post_hash[:text]
|
42
|
+
@created_at = post_hash[:created_at]
|
43
|
+
@user = post_hash[:user]
|
44
|
+
@video_file = post_hash[:video_file]
|
45
|
+
@video_preview_image_file = post_hash[:video_preview_image_file]
|
46
|
+
@video_preview_image_url = post_hash[:video_preview_image_url]
|
47
|
+
@screenshot_file = post_hash[:screenshot_file]
|
48
|
+
end
|
49
|
+
|
50
|
+
class << self
|
51
|
+
private
|
52
|
+
|
53
|
+
def scrape(urls)
|
54
|
+
urls.map do |url|
|
55
|
+
post_hash = Forki::PostScraper.new.parse(url)
|
56
|
+
Post.new(post_hash)
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|