Created
July 16, 2023 14:08
-
-
Save x4d3/332b035de75d0159609ba822a8e826a6 to your computer and use it in GitHub Desktop.
Process Links to follow redirection
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'bundler/inline' | |
gemfile do | |
source 'https://rubygems.org' | |
gem 'parallel' | |
end | |
links = <<-LINKS | |
Engineering at Meta - https://lnkd.in/e8tiSkEv | |
Google Research - https://ai.googleblog.com/ | |
Google Cloud Blog - https://lnkd.in/enNviCF8 | |
AWS Architecture Blog - https://lnkd.in/eEchKJif | |
All Things Distributed - https://lnkd.in/emXaQDaS | |
LINKS | |
processed = Parallel.map(links.split("\n")) do |link| | |
description, url = link.split(" - ") | |
followed_url = `curl -s -L -I -o /dev/null -w %{url_effective} #{url}` | |
[description, followed_url] | |
end | |
processed.each do |link| | |
description, url = link | |
puts " - [#{description}](#{url})" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment