a script for refreshing bad pinboard archives
change
commit ce1133654a34866c8adf4c425754f7d0421c956f
author Alpha Chen <alpha@kejadlen.dev>
date
parent 002d99c9
diff --git a/Gemfile b/Gemfile
index e76dde0..d946703 100644
--- a/Gemfile
+++ b/Gemfile
@@ -4,6 +4,8 @@ source "https://rubygems.org"
 
 git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
 
+gem "capybara"
 gem "minitest"
 gem "pry"
 gem "rake"
+gem "selenium-webdriver"
diff --git a/Gemfile.lock b/Gemfile.lock
index d4af900..f719a92 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -1,21 +1,49 @@
 GEM
   remote: https://rubygems.org/
   specs:
+    addressable (2.7.0)
+      public_suffix (>= 2.0.2, < 5.0)
+    capybara (3.33.0)
+      addressable
+      mini_mime (>= 0.1.3)
+      nokogiri (~> 1.8)
+      rack (>= 1.6.0)
+      rack-test (>= 0.6.3)
+      regexp_parser (~> 1.5)
+      xpath (~> 3.2)
+    childprocess (3.0.0)
     coderay (1.1.3)
     method_source (1.0.0)
+    mini_mime (1.0.2)
+    mini_portile2 (2.4.0)
     minitest (5.14.1)
+    nokogiri (1.10.10)
+      mini_portile2 (~> 2.4.0)
     pry (0.13.1)
       coderay (~> 1.1)
       method_source (~> 1.0)
+    public_suffix (4.0.5)
+    rack (2.2.3)
+    rack-test (1.1.0)
+      rack (>= 1.0, < 3)
     rake (13.0.1)
+    regexp_parser (1.7.1)
+    rubyzip (2.3.0)
+    selenium-webdriver (3.142.7)
+      childprocess (>= 0.5, < 4.0)
+      rubyzip (>= 1.2.2)
+    xpath (3.2.0)
+      nokogiri (~> 1.8)
 
 PLATFORMS
   ruby
 
 DEPENDENCIES
+  capybara
   minitest
   pry
   rake
+  selenium-webdriver
 
 BUNDLED WITH
    2.1.4
diff --git a/refresh-pinboard-500s.rb b/refresh-pinboard-500s.rb
new file mode 100755
index 0000000..c296e26
--- /dev/null
+++ b/refresh-pinboard-500s.rb
@@ -0,0 +1,42 @@
+#!/usr/bin/env ruby
+
+# require "bundler/inline"
+
+# gemfile do
+#   source "https://rubygems.org"
+#   gem "capybara"
+# end
+
+require "bundler/setup"
+
+def suppress_warnings
+  original_verbosity = $VERBOSE
+  $VERBOSE = nil
+  yield
+  $VERBOSE = original_verbosity
+end
+
+require "capybara"
+Capybara.default_driver = :selenium
+
+require "selenium/webdriver"
+Selenium::WebDriver::Firefox::Binary.path = "/Applications/Firefox\ Developer\ Edition.app/Contents/MacOS/firefox"
+
+require "capybara/dsl"
+suppress_warnings do
+  include Capybara::DSL
+end
+
+suppress_warnings do
+  visit "https://pinboard.in"
+end
+
+fill_in "username", with: ENV.fetch("PINBOARD_USERNAME")
+fill_in "password", with: ENV.fetch("PINBOARD_PASSWORD")
+click_button "log in"
+
+visit "https://pinboard.in/u:kejadlen/code:500"
+
+all(:xpath, "//a[@title='Click to re-crawl this link']").each do |link|
+  link.click
+end