Skip to content

Instantly share code, notes, and snippets.

@test0n3
Created May 2, 2023 17:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save test0n3/711dafa83c46d3bf2bf702abd46f4048 to your computer and use it in GitHub Desktop.
Save test0n3/711dafa83c46d3bf2bf702abd46f4048 to your computer and use it in GitHub Desktop.
Procedure to get the schedule (main date) from https://holamundo.day/
# frozen_string_literal: true
require 'uri'
require 'net/http'
require 'nokogiri'
# class GetSchedule, get on date schedule
class GetSchedule
HOLAMUNDO_URL = 'https://holamundo.day/'
def pick_data
uri = URI(HOLAMUNDO_URL)
res = Net::HTTP.get_response(uri)
print_schedule(res.body) if res.is_a?(Net::HTTPSuccess)
end
def print_schedule(response)
doc = Nokogiri::HTML(response)
schedule = find_schedules(doc)[0]
clean_html_snip(schedule).drop(8).map(&:content)
end
def find_schedules(html_body)
html_body.css('article.notion-page-content-inner').select do |article|
article.content.downcase.match?(/(agenda 8 de mayo)/)
end
end
def clean_html_snip(html_snip)
html_snip.children.select { |elem| elem.name == 'h1' || elem.name == 'blockquote' }
end
end
puts GetSchedule.new.pick_data
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment