Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .ruby-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.1.4
3.2.7
189 changes: 109 additions & 80 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5,37 +5,39 @@ PATH
apparition
capybara
oj
selenium-webdriver
selenium-webdriver (~> 4.40.0)
semantic_logger
typhoeus
zorki

GEM
remote: https://rubygems.org/
specs:
activesupport (7.2.2.1)
activesupport (8.1.2)
base64
benchmark (>= 0.3)
bigdecimal
concurrent-ruby (~> 1.0, >= 1.3.1)
connection_pool (>= 2.2.5)
drb
i18n (>= 1.6, < 2)
json
logger (>= 1.4.2)
minitest (>= 5.1)
securerandom (>= 0.3)
tzinfo (~> 2.0, >= 2.0.5)
addressable (2.8.7)
public_suffix (>= 2.0.2, < 7.0)
uri (>= 0.13.1)
addressable (2.8.8)
public_suffix (>= 2.0.2, < 8.0)
apparition (0.6.0)
capybara (~> 3.13, < 4)
websocket-driver (>= 0.6.5)
ast (2.4.2)
ast (2.4.3)
backport (1.2.0)
base64 (0.2.0)
benchmark (0.4.0)
bigdecimal (3.1.9)
byebug (11.1.3)
base64 (0.3.0)
benchmark (0.5.0)
bigdecimal (4.0.1)
byebug (13.0.0)
reline (>= 0.6.0)
capybara (3.40.0)
addressable
matrix
Expand All @@ -45,92 +47,107 @@ GEM
rack-test (>= 0.6.3)
regexp_parser (>= 1.5, < 3.0)
xpath (~> 3.2)
concurrent-ruby (1.3.5)
connection_pool (2.5.0)
curb (1.0.9)
debug (1.9.2)
concurrent-ruby (1.3.6)
connection_pool (3.0.2)
curb (1.2.2)
date (3.5.1)
debug (1.11.1)
irb (~> 1.10)
reline (>= 0.3.8)
diff-lcs (1.6.0)
diff-lcs (1.6.2)
dotenv (2.7.6)
drb (2.2.1)
ethon (0.16.0)
drb (2.2.3)
erb (6.0.1)
ethon (0.15.0)
ffi (>= 1.15.0)
ffi (1.17.1-arm64-darwin)
i18n (1.14.7)
ffi (1.17.3-arm64-darwin)
i18n (1.14.8)
concurrent-ruby (~> 1.0)
io-console (0.7.2)
irb (1.14.1)
io-console (0.8.2)
irb (1.17.0)
pp (>= 0.6.0)
prism (>= 1.3.0)
rdoc (>= 4.0.0)
reline (>= 0.4.2)
jaro_winkler (1.6.0)
json (2.10.1)
kramdown (2.5.1)
rexml (>= 3.3.9)
jaro_winkler (1.7.0)
json (2.18.1)
kramdown (2.5.2)
rexml (>= 3.4.4)
kramdown-parser-gfm (1.1.0)
kramdown (~> 2.0)
language_server-protocol (3.17.0.4)
language_server-protocol (3.17.0.5)
lint_roller (1.1.0)
logger (1.6.6)
matrix (0.4.2)
logger (1.7.0)
matrix (0.4.3)
mini_mime (1.1.5)
minitest (5.25.4)
nokogiri (1.18.3-arm64-darwin)
minitest (5.27.0)
nokogiri (1.19.0-arm64-darwin)
racc (~> 1.4)
observer (0.1.2)
oj (3.16.10)
oj (3.16.15)
bigdecimal (>= 3.0)
ostruct (>= 0.2)
ostruct (0.6.1)
parallel (1.26.3)
parser (3.3.7.1)
open3 (0.2.1)
ostruct (0.6.3)
parallel (1.27.0)
parser (3.3.10.1)
ast (~> 2.4.1)
racc
psych (5.2.0)
pp (0.6.3)
prettyprint
prettyprint (0.2.0)
prism (1.9.0)
psych (5.3.1)
date
stringio
public_suffix (6.0.1)
public_suffix (7.0.2)
racc (1.8.1)
rack (2.2.4)
rack-test (2.2.0)
rack (>= 1.3)
rainbow (3.1.1)
rake (13.2.1)
rbs (3.8.1)
rake (13.3.1)
rbs (3.10.3)
logger
rdoc (6.8.1)
tsort
rdoc (7.2.0)
erb
psych (>= 4.0.0)
regexp_parser (2.10.0)
reline (0.5.12)
tsort
regexp_parser (2.11.3)
reline (0.6.3)
io-console (~> 0.5)
reverse_markdown (3.0.0)
reverse_markdown (3.0.2)
nokogiri
rexml (3.4.1)
rubocop (1.72.2)
rexml (3.4.4)
rubocop (1.84.1)
json (~> 2.3)
language_server-protocol (~> 3.17.0.2)
lint_roller (~> 1.1.0)
parallel (~> 1.10)
parser (>= 3.3.0.2)
rainbow (>= 2.2.2, < 4.0)
regexp_parser (>= 2.9.3, < 3.0)
rubocop-ast (>= 1.38.0, < 2.0)
rubocop-ast (>= 1.49.0, < 2.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 2.4.0, < 4.0)
rubocop-ast (1.38.0)
parser (>= 3.3.1.0)
rubocop-md (2.0.0)
rubocop-ast (1.49.0)
parser (>= 3.3.7.2)
prism (~> 1.7)
rubocop-md (2.0.4)
lint_roller (~> 1.1)
rubocop (>= 1.72.1)
rubocop-minitest (0.37.1)
rubocop-minitest (0.38.2)
lint_roller (~> 1.1)
rubocop (>= 1.72.1, < 2.0)
rubocop (>= 1.75.0, < 2.0)
rubocop-ast (>= 1.38.0, < 2.0)
rubocop-packaging (0.5.2)
rubocop (>= 1.33, < 2.0)
rubocop-performance (1.24.0)
lint_roller (~> 1.1)
rubocop-packaging (0.6.0)
lint_roller (~> 1.1.0)
rubocop (>= 1.72.1, < 2.0)
rubocop-ast (>= 1.38.0, < 2.0)
rubocop-performance (1.26.1)
lint_roller (~> 1.1)
rubocop (>= 1.75.0, < 2.0)
rubocop-ast (>= 1.47.1, < 2.0)
rubocop-rails (2.17.4)
activesupport (>= 4.2.0)
rack (>= 1.1)
Expand All @@ -144,66 +161,78 @@ GEM
rubocop-performance (~> 1.11)
rubocop-rails (~> 2.0)
ruby-progressbar (1.13.0)
rubyzip (2.4.1)
rubyzip (3.2.2)
securerandom (0.4.1)
selenium-devtools (0.133.0)
selenium-devtools (0.143.0)
selenium-webdriver (~> 4.2)
selenium-webdriver (4.25.0)
selenium-webdriver (4.40.0)
base64 (~> 0.2)
logger (~> 1.4)
rexml (~> 3.2, >= 3.2.5)
rubyzip (>= 1.2.2, < 3.0)
rubyzip (>= 1.2.2, < 4.0)
websocket (~> 1.0)
semantic_logger (4.16.1)
semantic_logger (4.17.0)
concurrent-ruby (~> 1.0)
solargraph (0.51.2)
solargraph (0.58.2)
ast (~> 2.4.3)
backport (~> 1.2)
benchmark
bundler (~> 2.0)
benchmark (~> 0.4)
bundler (>= 2.0)
diff-lcs (~> 1.4)
jaro_winkler (~> 1.6)
jaro_winkler (~> 1.6, >= 1.6.1)
kramdown (~> 2.3)
kramdown-parser-gfm (~> 1.1)
logger (~> 1.6)
observer (~> 0.1)
open3 (~> 0.2.1)
ostruct (~> 0.6)
parser (~> 3.0)
rbs (~> 3.0)
reverse_markdown (>= 2.0, < 4)
rubocop (~> 1.38)
prism (~> 1.4)
rbs (>= 3.6.1, <= 4.0.0.dev.4)
reverse_markdown (~> 3.0)
rubocop (~> 1.76)
thor (~> 1.0)
tilt (~> 2.0)
yard (~> 0.9, >= 0.9.24)
stringio (3.1.2)
thor (1.3.2)
tilt (2.6.0)
typhoeus (1.4.1)
ethon (>= 0.9.0)
yard-activesupport-concern (~> 0.0)
yard-solargraph (~> 0.1)
stringio (3.2.0)
thor (1.5.0)
tilt (2.7.0)
tsort (0.2.0)
typhoeus (1.5.0)
ethon (>= 0.9.0, < 0.16.0)
tzinfo (2.0.6)
concurrent-ruby (~> 1.0)
unicode-display_width (3.1.4)
unicode-emoji (~> 4.0, >= 4.0.4)
unicode-emoji (4.0.4)
unicode-display_width (3.2.0)
unicode-emoji (~> 4.1)
unicode-emoji (4.2.0)
uri (1.1.1)
websocket (1.2.11)
websocket-driver (0.7.7)
websocket-driver (0.8.0)
base64
websocket-extensions (>= 0.1.0)
websocket-extensions (0.1.5)
xpath (3.2.0)
nokogiri (~> 1.8)
yard (0.9.37)
zorki (0.2.8)
yard (0.9.38)
yard-activesupport-concern (0.0.1)
yard (>= 0.8)
yard-solargraph (0.1.0)
yard (~> 0.9)
zorki (0.1.24)
apparition
capybara
oj
selenium-devtools
selenium-webdriver (~> 4.25.0)
selenium-webdriver (~> 4.19)
typhoeus

PLATFORMS
arm64-darwin-21
arm64-darwin-22
arm64-darwin-23
arm64-darwin-24

DEPENDENCIES
byebug
Expand All @@ -221,4 +250,4 @@ DEPENDENCIES
thor

BUNDLED WITH
2.3.11
2.4.19
67 changes: 67 additions & 0 deletions bin/login_and_save_cookies.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
#!/usr/bin/env ruby
require "bundler/setup"
require "forki"

Capybara.default_max_wait_time = 5 # Reducir de 60s a 5s para evitar cuelgues

scraper = Forki::PostScraper.new
page = scraper.send(:page)

puts "Haciendo login..."
scraper.send(:login)
puts "Login completado. Logged in: #{scraper.logged_in}"
puts "Página: #{page.title}"
sleep(5)

# Buscar campo de código de seguridad
puts "\nBuscando campo de código de seguridad..."
code_field = nil
['input[name="approvals_code"]', 'input[id="approvals_code"]',
'input[autocomplete="one-time-code"]', 'input[type="text"]'].each do |sel|
begin
code_field = page.find(sel, wait: 2)
puts "Campo encontrado: #{sel}"
break
rescue Capybara::ElementNotFound; end
end

if code_field
print "\n*** Introduce el código de seguridad: "
$stdout.flush
code = $stdin.gets.chomp

code_field.set(code)
sleep(1)

puts "Enviando código (Enter)..."
code_field.send_keys(:return)
sleep(5)

puts "Tras enviar - Página: #{page.title}"
puts "URL: #{page.current_url}"

# Manejar "Save this browser?" u otros prompts
begin
btns = page.all(:xpath, '//*[@role="button"]', wait: 3)
btns.each { |b| puts " Botón visible: '#{b.text.strip}'" }
ok = btns.find { |b| b.text.strip =~ /ok|save|continue|not now/i }
ok&.click
sleep(3)
rescue => e
puts "Sin prompts adicionales"
end

puts "\nEstado final:"
puts " Página: #{page.title}"
puts " URL: #{page.current_url}"
else
puts "No se encontró campo de código"
end

puts "\nGuardando cookies..."
cookies = page.driver.browser.manage.all_cookies
File.write("forki_cookies.json", cookies.to_json)
puts "Guardadas #{cookies.count} cookies."

page.quit
puts "Listo."
2 changes: 1 addition & 1 deletion forki.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ Gem::Specification.new do |spec|
spec.add_dependency "apparition" # A Chrome driver for Capybara
spec.add_dependency "typhoeus" # For making API requests
spec.add_dependency "oj" # A faster JSON parser/loader than stdlib
spec.add_dependency "selenium-webdriver" # Webdriver selenium
spec.add_dependency "selenium-webdriver", "~> 4.40.0" # Webdriver selenium
spec.add_dependency "zorki" # For scraping instagram pages
spec.add_dependency "semantic_logger" # For logging

Expand Down
Loading